Пример #1
0
  /**
   * @param name
   * @param bufferSize
   * @param concurrency
   * @param uncaughtExceptionHandler
   * @param shutdownHandler
   * @param autoShutdown
   * @param waitStrategy
   * @param <E>
   * @return
   */
  public static <E> ProcessorGroup<E> ioGroup(
      final String name,
      final int bufferSize,
      int concurrency,
      Consumer<Throwable> uncaughtExceptionHandler,
      Runnable shutdownHandler,
      boolean autoShutdown,
      WaitStrategy waitStrategy) {

    return ProcessorGroup.create(
        ProcessorWorkQueue.<Runnable>share(name, bufferSize, waitStrategy, false),
        concurrency,
        uncaughtExceptionHandler,
        shutdownHandler,
        autoShutdown);
  }
Пример #2
0
  /**
   * @param name
   * @param bufferSize
   * @param uncaughtExceptionHandler
   * @param shutdownHandler
   * @param autoShutdown
   * @param waitprovider
   * @param <E>
   * @return
   */
  public static <E> ProcessorGroup<E> asyncGroup(
      final String name,
      final int bufferSize,
      final int concurrency,
      Consumer<Throwable> uncaughtExceptionHandler,
      Runnable shutdownHandler,
      boolean autoShutdown,
      final Supplier<? extends WaitStrategy> waitprovider) {

    return ProcessorGroup.create(
        new Supplier<Processor<Runnable, Runnable>>() {
          int i = 1;

          @Override
          public Processor<Runnable, Runnable> get() {
            return ProcessorTopic.share(
                name + (concurrency > 1 ? "-" + (i++) : ""), bufferSize, waitprovider.get(), false);
          }
        },
        concurrency,
        uncaughtExceptionHandler,
        shutdownHandler,
        autoShutdown);
  }