Class ScheduledObjectOneWorkRunnable<O>

  • Type Parameters:
    O - The type of object for which to run.
    All Implemented Interfaces:
    ObjectRunnable<O,​O>, Runnable

    public class ScheduledObjectOneWorkRunnable<O>
    extends AbstractObjectRunnable<O,​O,​ScheduledObjectOneWorkExecutor.ScheduledRuntimeData>
    A runnable that will enqueue a delayed object runnable as soon as the delay elapsed.
    This runnable is used within a scheduled executor. When running, it removes the delayed runnable from the corresponding runtime data and makes it available as new (pending) work to be executed normally. Whether the work is then before or after a flush depends on whether a flush is currently pending or whether the executor should block until after flash there has already been work done for this object after the previous flush.
    • Field Detail

      • executor

        protected final ScheduledObjectOneWorkExecutor<O> executor
        The executor to which to add the delayed runnable as soon as this scheduled ObjectRunnable is eventually executed.
    • Constructor Detail

      • ScheduledObjectOneWorkRunnable

        public ScheduledObjectOneWorkRunnable​(O object,
                                              ScheduledObjectOneWorkExecutor<O> executor,
                                              AtomicInteger terminate,
                                              Logger logger)
        Creates a new ObjectRunnable that enqueues a delayed runnable to be executed for a specific object after a specific delay.
        Parameters:
        object - The object of this runnable.
        executor - The executor to which to add the delayed runnable.
        terminate - The amount of termination requests. This allows for synchronising across different objects.
        logger - The logger which to use for the progress of enqueueing the delayed runnable.
    • Method Detail

      • runForObject

        protected boolean runForObject()
        Description copied from class: AbstractObjectRunnable
        Runs this runnable actually. Activation and termination signalling are already handled, implementations only need to react to termination requests.
        Specified by:
        runForObject in class AbstractObjectRunnable<O,​O,​ScheduledObjectOneWorkExecutor.ScheduledRuntimeData>
        Returns:
        Whether the work for the object has been terminated. Otherwise there is work left and the termination is not signalled. With a termination request, return true, only return false if you want to continue to work without interruption, e.g. to change the executing thread.