Groovy Documentation

org.linkedin.glu.groovy.utils.concurrent
[Groovy] Class FutureTaskExecution

java.lang.Object
  org.linkedin.glu.groovy.utils.concurrent.FutureTaskExecution

class FutureTaskExecution

Authors:
yan@pongasoft.com


Field Summary
static Submitter DEFAULT_SUBMITTER

protected java.util.concurrent.Callable _callable

The callable assigned in the constructor (if any)

protected java.util.concurrent.FutureTask _future

The actual future task on which all the calls will be delegated to implement the Future interface

protected groovy.lang.Closure _onCompletionCallback

Callback to be called once the future ends

protected boolean _onCompletionCallbackCalled

set when the completion callback has been called

 
Property Summary
Clock clock

The clock

long completionTime

when the execution completes

java.lang.String description

An (optional) description for the task

long futureExecutionTime

when the execution should start (0 means start now)

long startTime

when the execution started

 
Constructor Summary
FutureTaskExecution()

In this case, the execute method will be called

FutureTaskExecution(java.util.concurrent.Callable callable)

execute the callable

FutureTaskExecution(groovy.lang.Closure closure)

execute the closure

 
Method Summary
boolean cancel(boolean mayInterruptIfRunning)

protected T execute()

T get(java.lang.Object timeout)

T get()

T get(long timeout, java.util.concurrent.TimeUnit unit)

java.lang.String getId()

groovy.lang.Closure getOnCompletionCallback()

boolean isCancelled()

boolean isDone()

boolean isStarted()

void run()

FutureTaskExecution runAsync(Submitter submitter = DEFAULT_SUBMITTER)

Runs asynchronously.

T runSync()

Runs synchronously.

void setId(java.lang.String id)

void setOnCompletionCallback(groovy.lang.Closure onCompletionCallback)

This method ensures that the completion callback is called even if the command has already run and is completed!

void waitForStart(java.lang.Object timeout = null)

 
Methods inherited from class java.lang.Object
java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()
 

Field Detail

DEFAULT_SUBMITTER

public static final Submitter DEFAULT_SUBMITTER


_callable

protected final java.util.concurrent.Callable _callable
The callable assigned in the constructor (if any)


_future

protected final java.util.concurrent.FutureTask _future
The actual future task on which all the calls will be delegated to implement the Future interface


_onCompletionCallback

protected groovy.lang.Closure _onCompletionCallback
Callback to be called once the future ends


_onCompletionCallbackCalled

protected boolean _onCompletionCallbackCalled
set when the completion callback has been called


 
Property Detail

clock

Clock clock
The clock


completionTime

long completionTime
when the execution completes


description

java.lang.String description
An (optional) description for the task


futureExecutionTime

long futureExecutionTime
when the execution should start (0 means start now)


startTime

long startTime
when the execution started


 
Constructor Detail

FutureTaskExecution

FutureTaskExecution()
In this case, the execute method will be called


FutureTaskExecution

FutureTaskExecution(java.util.concurrent.Callable callable)
execute the callable


FutureTaskExecution

FutureTaskExecution(groovy.lang.Closure closure)
execute the closure


 
Method Detail

cancel

@Override
boolean cancel(boolean mayInterruptIfRunning)


execute

protected T execute()


get

T get(java.lang.Object timeout)


get

@Override
T get()


get

@Override
T get(long timeout, java.util.concurrent.TimeUnit unit)


getId

@Override
java.lang.String getId()


getOnCompletionCallback

groovy.lang.Closure getOnCompletionCallback()


isCancelled

@Override
boolean isCancelled()


isDone

@Override
boolean isDone()


isStarted

boolean isStarted()


run

void run()


runAsync

FutureTaskExecution runAsync(Submitter submitter = DEFAULT_SUBMITTER)
Runs asynchronously. Uses the submitter to run asynchronously. Returns right away.
Returns:
this for convenience


runSync

T runSync()
Runs synchronously. (blocks until completed)


setId

void setId(java.lang.String id)


setOnCompletionCallback

void setOnCompletionCallback(groovy.lang.Closure onCompletionCallback)
This method ensures that the completion callback is called even if the command has already run and is completed!


waitForStart

void waitForStart(java.lang.Object timeout = null)


 

Groovy Documentation