Constructor and Description |
---|
Runner()
Makes a Runner, and starts the thread that services its queue.
|
Runner(String name)
Makes a Runner, and starts the thread that services its queue.
|
Modifier and Type | Method and Description |
---|---|
static Runner |
currentRunner()
If called from within a thread servicing a Runner, returns that
Runner.
|
void |
enqueue(Runnable todo)
Queues something for this Runnable's thread to do.
|
boolean |
isCurrentThreadInRunner()
Tests whether the current thread is holding the run lock
|
boolean |
isShuttingDown()
Tests if an orderlyShutdown been requested.
|
Object |
now(Callable<Object> todo)
Schedules a thunk to execute "inside" this runner (in the RunnerThread
as a separate turn while holding the runLock), while also effectively
executing as a synchronous call within the requestors's thread.
|
void |
orderlyShutdown()
Will enqueue a request to shut down this runner's thread.
|
void |
run()
Called only by
Thread.start() . |
static void |
throwIfMandatory(Throwable t)
Utility routine to either swallow or throw exceptions, depending on
whether or not they are the kind of exceptions that need to escape from
the run loop.
|
public Runner()
public Runner(String name)
name
- is the name to give to the thread created.public static Runner currentRunner()
public static void throwIfMandatory(Throwable t)
public void enqueue(Runnable todo)
public boolean isCurrentThreadInRunner()
public Object now(Callable<Object> todo)
public void orderlyShutdown()
public boolean isShuttingDown()
public void run()
Thread.start()
. Pulls Runnables off of the queue
until there aren't any more, then waits until there's more to do.Copyright © 2017. All rights reserved.