com.sun.grizzly.impl
Class FutureImpl<R>

java.lang.Object
  extended by com.sun.grizzly.impl.FutureImpl<R>
All Implemented Interfaces:
Future<R>

public class FutureImpl<R>
extends Object
implements Future<R>

Simple Future implementation, which uses synchronization Object to synchronize during the lifecycle.

Author:
Alexey Stashok
See Also:
Future

Field Summary
protected  R result
           
 
Constructor Summary
FutureImpl()
           
FutureImpl(Object sync)
           
 
Method Summary
 boolean cancel(boolean mayInterruptIfRunning)
          
 void failure(Throwable failure)
          Notify about the failure, occured during asynchronous operation execution.
 R get()
          
 R get(long timeout, TimeUnit unit)
          
 R getResult()
          Get current result value without any blocking.
 boolean isCancelled()
          
 boolean isDone()
          
protected  void notifyHaveResult()
          Notify blocked listeners threads about operation completion.
 void setResult(R result)
          Set the result value and notify about operation completion.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

result

protected R result
Constructor Detail

FutureImpl

public FutureImpl()

FutureImpl

public FutureImpl(Object sync)
Method Detail

getResult

public R getResult()
Get current result value without any blocking.

Returns:
current result value without any blocking.

setResult

public void setResult(R result)
Set the result value and notify about operation completion.

Parameters:
result - the result value

cancel

public boolean cancel(boolean mayInterruptIfRunning)

Specified by:
cancel in interface Future<R>

isCancelled

public boolean isCancelled()

Specified by:
isCancelled in interface Future<R>

isDone

public boolean isDone()

Specified by:
isDone in interface Future<R>

get

public R get()
      throws InterruptedException,
             ExecutionException

Specified by:
get in interface Future<R>
Throws:
InterruptedException
ExecutionException

get

public R get(long timeout,
             TimeUnit unit)
      throws InterruptedException,
             ExecutionException,
             TimeoutException

Specified by:
get in interface Future<R>
Throws:
InterruptedException
ExecutionException
TimeoutException

failure

public void failure(Throwable failure)
Notify about the failure, occured during asynchronous operation execution.

Parameters:
failure -

notifyHaveResult

protected void notifyHaveResult()
Notify blocked listeners threads about operation completion.



Copyright © 2009 SUN Microsystems. All Rights Reserved.