Package org.eclipse.net4j.util.concurrent

## Class QueueWorker<E>

- java.lang.Object
- - org.eclipse.net4j.util.event.Notifier
  - - org.eclipse.net4j.util.lifecycle.Lifecycle
    - - org.eclipse.net4j.util.concurrent.Worker
      - - org.eclipse.net4j.util.concurrent.QueueWorker<E>

- All Implemented Interfaces:
    `INotifier`, `INotifier.INotifier2`, `IDeactivateable`, `ILifecycle`, `ILifecycle.DeferrableActivation`
  Direct Known Subclasses:
    `QueueRunner`, `QueueRunner2`

      public abstract class QueueWorker<E>
      extends Worker

  Since:
    2.0
  Author:
    Eike Stepper

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.eclipse.net4j.util.concurrent.Worker

      `Worker.WorkContext`

    - ### Nested classes/interfaces inherited from interface org.eclipse.net4j.util.lifecycle.ILifecycle

      `ILifecycle.DeferrableActivation`

    - ### Nested classes/interfaces inherited from interface org.eclipse.net4j.util.event.INotifier

      `INotifier.INotifier2`

  - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static int` | `DEFAULT_POLL_MILLIS` |

    - ### Fields inherited from class org.eclipse.net4j.util.concurrent.Worker

      `DEFAULT_ERROR_HANDLER, DEFAULT_TIMEOUT`

    - ### Fields inherited from class org.eclipse.net4j.util.lifecycle.Lifecycle

      `USE_LABEL`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `QueueWorker()` |

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `boolean` | `addWork​(E element)` |
    `void` | `clearQueue()` |
    `protected java.util.concurrent.BlockingQueue<E>` | `createQueue()` |
    `protected void` | `doDeactivate()` |
    `protected boolean` | `doRemainingWorkBeforeDeactivate()` |
    `long` | `getPollMillis()` |
    `protected void` | `noWork​(Worker.WorkContext context)` |
    `void` | `setPollMillis​(long pollMillis)` |
    `protected void` | `work​(Worker.WorkContext context)` |
    `protected abstract void` | `work​(Worker.WorkContext context, E element)` |

    - ### Methods inherited from class org.eclipse.net4j.util.concurrent.Worker

      `doActivate, getActivationTimeout, getDeactivationTimeout, getGlobalErrorHandler, getThreadName, getWorkerThread, handleError, isDaemon, setActivationTimeout, setDaemon, setDeactivationTimeout, setGlobalErrorHandler`

    - ### Methods inherited from class org.eclipse.net4j.util.lifecycle.Lifecycle

      `activate, checkActive, checkArg, checkArg, checkInactive, checkNull, checkState, checkState, deactivate, deferredActivate, doAfterActivate, doBeforeActivate, doBeforeDeactivate, dump, getLifecycleState, isActive, isDeferredActivation, toString`

    - ### Methods inherited from class org.eclipse.net4j.util.event.Notifier

      `addListener, addUniqueListener, fireEvent, fireEvent, fireEvent, fireThrowable, firstListenerAdded, getListeners, getNotificationService, hasListener, hasListeners, lastListenerRemoved, listenerAdded, listenerRemoved, removeListener`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface org.eclipse.net4j.util.event.INotifier

      `addListener, getListeners, hasListeners, removeListener`

- - ### Field Detail

    - #### DEFAULT_POLL_MILLIS

          public static final int DEFAULT_POLL_MILLIS

      Since:
        3.2
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### QueueWorker

          public QueueWorker()

  - ### Method Detail

    - #### getPollMillis

          public long getPollMillis()

    - #### setPollMillis

          public void setPollMillis​(long pollMillis)

    - #### clearQueue

          public void clearQueue()

      Since:
        3.0

    - #### addWork

          public boolean addWork​(E element)

    - #### work

          protected void work​(Worker.WorkContext context)
                       throws java.lang.Exception

      Specified by:
        `work` in class `Worker`
      Throws:
        `java.lang.Exception`

    - #### work

          protected abstract void work​(Worker.WorkContext context,
                                       E element)

    - #### noWork

          protected void noWork​(Worker.WorkContext context)

      Since:
        3.3

    - #### createQueue

          protected java.util.concurrent.BlockingQueue<E> createQueue()

    - #### doRemainingWorkBeforeDeactivate

          protected boolean doRemainingWorkBeforeDeactivate()

      Since:
        3.1

    - #### doDeactivate

          protected void doDeactivate()
                               throws java.lang.Exception

      Overrides:
        `doDeactivate` in class `Worker`
      Throws:
        `java.lang.Exception`