Class ConcurrentTaskQueue<R>

java.lang.Object
ch.ladestation.connectncharge.util.mvcbase.ConcurrentTaskQueue<R>

public final class ConcurrentTaskQueue<R> extends Object
A device where tasks can be submitted for execution.

Execution is asynchronous - possibly in a different thread - but the sequence is kept stable, such that for all tasks A and B: if B is submitted after A, B will only be executed after A is finished.

New tasks can be submitted while tasks are running.

Task submission itself is supposed to be thread-confined, i.e. creation of the ConcurrentTaskQueue and task submission is expected to run in the same thread, most likely the JavaFX UI Application Thread.

Author:
Dierk Koenig
  • Constructor Details

    • ConcurrentTaskQueue

      public ConcurrentTaskQueue()
    • ConcurrentTaskQueue

      public ConcurrentTaskQueue(Duration maxToDoTime)
  • Method Details

    • shutdown

      public void shutdown()
    • submit

      public void submit(Supplier<R> todo)
    • submit

      public void submit(Supplier<R> todo, Consumer<R> onDone)