public interface ConcurrencyService
| Modifier and Type | Method and Description |
|---|---|
boolean |
flush(Thread thread,
int timeout)
Flushes all jobs for a given thread, up to a given millisecond timeout.
|
boolean |
kill(Thread thread,
int timeout)
Flushes all jobs for the given thread, and then kills it.
|
AsyncLock |
newLock() |
<T> ProcessController<T> |
newProcess(Process<T> process)
Experimental; may replace
newThread(Runnable). |
Thread |
newThread(Runnable cmd)
Experimental; may be deprecated.
|
double |
now() |
<T> void |
resolve(Future<T> future,
ReceivesValue<T> receiver)
Resolves a future in another thread / using a shared poller.
|
void |
runDeferred(Runnable cmd)
Runs the given command in a new environment, after all finalies have been
processed.
|
void |
runEventually(Runnable cmd)
Runs the command eventually, most likely on an unused thread.
|
void |
runFinally(Runnable cmd)
Runs the given command after the work queue for the current environment
is drained.
|
void |
runTimeout(Runnable cmd,
int millisToWait)
Wait (at least) a given number of milliseconds to perform a task.
|
double |
threadStartTime(Thread currentThread)
Tells what time the current process for the current thread started.
|
boolean |
trySleep(float millis)
Attempts to sleep, if the current thread is not interrupted.
|
Thread newThread(Runnable cmd)
cmd - - The command to wrap in a new thread.<T> ProcessController<T> newProcess(Process<T> process)
newThread(Runnable).
Accepts an instance of Process, and returns a ProcessController.
Designed to give an abstract action-oriented workflow that functions in
both threadsafe and singlethreaded environments.process - void runDeferred(Runnable cmd)
cmd - - The task to run.void runFinally(Runnable cmd)
cmd - - The command to run after the work queue is drained.void runTimeout(Runnable cmd, int millisToWait)
cmd - - The command to run.millisToWait - - A minimum of milliseconds to wait.void runEventually(Runnable cmd)
cmd - - A command to run whenever there is time.
No guarantee is made about how soon or how later the process is run.
A best-effort is made to use warm threads with nothing better to do
to process eventually commands.<T> void resolve(Future<T> future, ReceivesValue<T> receiver)
future - - The future to wait upon.receiver - - The handler to receive the value.
If received is an instanceof ErrorHandler, it will receive
any exceptions caused by the future (after unwrapping ExecutionException
and RuntimeException).boolean flush(Thread thread, int timeout)
thread - - The thread to finish.timeout - - The maximum time to take. Send 0 to wait indefinitely.boolean kill(Thread thread, int timeout)
thread - - The thread to finish and then kill.timeout - - How many milliseconds to wait for a graceful shutdown.boolean trySleep(float millis)
millis - - The millis to wait. Floating point converts to nanos.double threadStartTime(Thread currentThread)
currentThread - - The thread who's start time to check.double now()
TimeService.birth().AsyncLock newLock()
Copyright © December 07, 2012–2015 The Internet Party. All rights reserved.