public class ThreadPoolContext extends Object implements ThreadContext
This is a special ThreadContext implementation that schedules events to be executed
on a thread pool. Events executed by this context are guaranteed to be executed on order but may be executed on different
threads in the provided thread pool.
| Constructor and Description |
|---|
ThreadPoolContext(ScheduledExecutorService parent,
Serializer serializer)
Creates a new thread pool context.
|
| Modifier and Type | Method and Description |
|---|---|
void |
block()
Sets the context state to blocked.
|
void |
close()
Closes the context.
|
Executor |
executor()
Returns the underlying executor.
|
boolean |
isBlocked()
Returns a boolean indicating whether the context state is blocked.
|
org.slf4j.Logger |
logger()
Returns the context logger.
|
Scheduled |
schedule(Duration delay,
Duration interval,
Runnable runnable)
Schedules a runnable at a fixed rate on the context.
|
Scheduled |
schedule(Duration delay,
Runnable runnable)
Schedules a runnable on the context.
|
Serializer |
serializer()
Returns the context serializer.
|
void |
unblock()
Sets the context state to unblocked.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcheckThread, currentContext, currentContextOrThrow, execute, execute, isCurrentContextpublic ThreadPoolContext(ScheduledExecutorService parent, Serializer serializer)
parent - The thread pool on which to execute events.serializer - The context serializer.public org.slf4j.Logger logger()
ThreadContextlogger in interface ThreadContextpublic Serializer serializer()
ThreadContextserializer in interface ThreadContextpublic boolean isBlocked()
ThreadContextisBlocked in interface ThreadContextpublic void block()
ThreadContextblock in interface ThreadContextpublic void unblock()
ThreadContextunblock in interface ThreadContextpublic Executor executor()
ThreadContextexecutor in interface ThreadContextpublic Scheduled schedule(Duration delay, Runnable runnable)
ThreadContextschedule in interface ThreadContextdelay - The delay at which to schedule the runnable.runnable - The callback to schedule.public Scheduled schedule(Duration delay, Duration interval, Runnable runnable)
ThreadContextschedule in interface ThreadContextrunnable - The callback to schedule.public void close()
ThreadContextclose in interface ThreadContextclose in interface AutoCloseableCopyright © 2013–2016. All rights reserved.