| Modifier and Type | Field and Description |
|---|---|
protected java.util.concurrent.locks.Lock |
lock
The lock protecting the queue.
|
java.util.concurrent.atomic.AtomicLong |
sequence
The relative order for zero delay invocations.
|
protected java.util.PriorityQueue<hu.akarnokd.reactive4java.scheduler.CurrentThreadScheduler.DelayedRunnable> |
tasks
The priority queue for the tasks.
|
protected java.util.concurrent.atomic.AtomicInteger |
wip
The in progress value.
|
| Constructor and Description |
|---|
CurrentThreadScheduler() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
add(hu.akarnokd.reactive4java.scheduler.CurrentThreadScheduler.DelayedRunnable dr)
Adds the given task.
|
protected hu.akarnokd.reactive4java.scheduler.CurrentThreadScheduler.DelayedRunnable |
poll()
Takes a task from the queue.
|
protected void |
remove(hu.akarnokd.reactive4java.scheduler.CurrentThreadScheduler.DelayedRunnable dr)
Removes the given task.
|
java.io.Closeable |
schedule(java.lang.Runnable run)
Schedule for ASAP execution.
|
java.io.Closeable |
schedule(java.lang.Runnable run,
long initialDelay,
long betweenDelay,
java.util.concurrent.TimeUnit unit)
Schedule a repeated execution of the given task with
the given initialDelay (in nanoseconds) and betweenDelay
(in nanoseconds).
|
java.io.Closeable |
schedule(java.lang.Runnable run,
long delay,
java.util.concurrent.TimeUnit unit)
Schedule a single execution of the runnable task
with the given delay of nanoseconds.
|
public final java.util.concurrent.atomic.AtomicLong sequence
protected final java.util.concurrent.atomic.AtomicInteger wip
protected final java.util.concurrent.locks.Lock lock
protected java.util.PriorityQueue<hu.akarnokd.reactive4java.scheduler.CurrentThreadScheduler.DelayedRunnable> tasks
protected void add(hu.akarnokd.reactive4java.scheduler.CurrentThreadScheduler.DelayedRunnable dr)
dr - the taskprotected void remove(hu.akarnokd.reactive4java.scheduler.CurrentThreadScheduler.DelayedRunnable dr)
dr - the taskprotected hu.akarnokd.reactive4java.scheduler.CurrentThreadScheduler.DelayedRunnable poll()
@Nonnull
public java.io.Closeable schedule(@Nonnull
java.lang.Runnable run)
Scheduler@Nonnull
public java.io.Closeable schedule(@Nonnull
java.lang.Runnable run,
long delay,
@Nonnull
java.util.concurrent.TimeUnit unit)
Scheduler@Nonnull
public java.io.Closeable schedule(@Nonnull
java.lang.Runnable run,
long initialDelay,
long betweenDelay,
@Nonnull
java.util.concurrent.TimeUnit unit)
SchedulerExecutorService.scheduleAtFixedRate()).
Note: Implementations might not have the capability to
schedule nanosecond resolution.