
public class KeyQueueExecutor extends Object
String keys associated with submitted tasks to sequence their execution.
Tasks submitted with overlapping key sets are guaranteed to execute sequentially in order of submission.
Tasks that do not have common keys may run concurrently, up to the specified maximum number of threads.| Constructor and Description |
|---|
KeyQueueExecutor(String name,
int maxThreads)
Constructs the executor.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
awaitTermination(long timeout,
TimeUnit unit)
Blocks until all tasks have completed execution after a shutdown request, or the
timeout occurs, or the current thread is interrupted, whichever happens first.
|
void |
execute(Runnable command,
String... keys)
Submits a Runnable for execution.
|
String |
getName()
Returns the name of this executor.
|
void |
setLogger(Logger logger)
Sets a logger for messages on abnormal conditions.
|
void |
shutdown()
Initiates an orderly shutdown in which previously submitted
tasks are executed, but no new tasks will be accepted.
|
void |
shutdownNow()
Shuts down this executor.
|
public KeyQueueExecutor(String name, int maxThreads)
name - Name of this executor, used for naming threads.maxThreads - Maximum number of task-executing threads that can run concurrently.public void setLogger(Logger logger)
logger - Logger for abnormal conditions warnings.public void shutdown()
public void shutdownNow()
public boolean awaitTermination(long timeout,
TimeUnit unit)
throws InterruptedException
timeout - the maximum time to waitunit - the time unit of the timeout argumenttrue if this executor terminated and
false if the timeout elapsed before terminationInterruptedException - if interrupted while waitingpublic String getName()
public void execute(Runnable command, String... keys)
This class is thread-safe, its methods can be called on any thread. Visibility effects: all actions of the current thread prior to calling this method "happen before" actions on the thread executing the task. Actions of a task "happen before" actions of another task submitted later with overlapping key set.
command - Runnable to execute.keys - KeysRejectedExecutionException - if this task cannot be accepted for execution.NullPointerException - if command is null.Copyright © 2020 LSST. All rights reserved.