public final class WorkerEnvironment extends java.lang.Object
Each port is internally associated to a worker function and a messages queue. The worker environment maintains an executor that dispatches message processing jobs over its thread pool.
| Modifier and Type | Class and Description | 
|---|---|
static class  | 
WorkerEnvironment.Builder
Worker environment builder objects exist mostly to provide a good-looking API in Golo. 
 | 
| Constructor and Description | 
|---|
WorkerEnvironment(java.util.concurrent.ExecutorService executor)
Creates a new worker environment using an executor. 
 | 
| Modifier and Type | Method and Description | 
|---|---|
boolean | 
awaitTermination(int millis)
Waits until all remaining messages have been processed. 
 | 
boolean | 
awaitTermination(long millis)
Waits until all remaining messages have been processed. 
 | 
boolean | 
awaitTermination(long timeout,
                java.util.concurrent.TimeUnit unit)
Waits until all remaining messages have been processed. 
 | 
static WorkerEnvironment.Builder | 
builder()  | 
boolean | 
isShutdown()  | 
boolean | 
isTerminated()  | 
static WorkerEnvironment | 
newWorkerEnvironment()  | 
WorkerEnvironment | 
shutdown()
Shutdown the worker environment. 
 | 
Port | 
spawn(FunctionReference func)
Spawns a worker function. 
 | 
Port | 
spawnWorker(WorkerFunction function)
Spawns a worker function. 
 | 
public WorkerEnvironment(java.util.concurrent.ExecutorService executor)
executor - the executor.public static WorkerEnvironment newWorkerEnvironment()
Executors.newCachedThreadPool()public static WorkerEnvironment.Builder builder()
public Port spawn(FunctionReference func)
func - the worker target.handle.public Port spawnWorker(WorkerFunction function)
function - the worker target.function.public WorkerEnvironment shutdown()
ExecutorService.shutdown()public boolean awaitTermination(int millis) throws java.lang.InterruptedException
millis - the delay.java.lang.InterruptedExceptionExecutorService.awaitTermination(long, java.util.concurrent.TimeUnit)public boolean awaitTermination(long millis) throws java.lang.InterruptedException
millis - the delay.java.lang.InterruptedExceptionExecutorService.awaitTermination(long, java.util.concurrent.TimeUnit)public boolean awaitTermination(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
timeout - the delay.unit - the delay time unit.java.lang.InterruptedExceptionExecutorService.awaitTermination(long, java.util.concurrent.TimeUnit)public boolean isShutdown()
ExecutorService.isShutdown()public boolean isTerminated()
ExecutorService.isTerminated()