Class GWorkQueue.Builder<T>

java.lang.Object
com.glitchybyte.glib.concurrent.workqueue.GWorkQueue.Builder<T>
Type Parameters:
T - Work item type.
Enclosing interface:
GWorkQueue<T>

public static class GWorkQueue.Builder<T> extends Object
GWorkQueue builder.
  • Constructor Details

    • Builder

      public Builder(String threadName, Consumer<T> processor, boolean parallelProcessing)
      Creates a GWorkQueueTask builder.
      Parameters:
      threadName - Thread name.
      processor - Work item processor.
      parallelProcessing - True, if work items should be processed in parallel.
    • Builder

      public Builder()
      Creates a GWorkQueue builder with default values.
  • Method Details

    • withThreadName

      public GWorkQueue.Builder<T> withThreadName(String threadName)
      Changes the thread name.
      Parameters:
      threadName - Thread name.
      Returns:
      A new builder with updated values.
    • withProcessor

      public GWorkQueue.Builder<T> withProcessor(Consumer<T> processor)
      Changes the work item processor.
      Parameters:
      processor - Work item processor.
      Returns:
      A new builder with updated values.
    • withParallelProcessing

      public GWorkQueue.Builder<T> withParallelProcessing(boolean parallelProcessing)
      Changes if work items should be processed in parallel or sequentially.
      Parameters:
      parallelProcessing - True, if work items should be processed in parallel.
      Returns:
      A new builder with updated values.
    • build

      public GWorkQueueTask<T> build()
      Builds a GWorkQueueTask ready to be started.
      Returns:
      A GWorkQueueTask ready to be started.