net.sf.cindy.session
Class DefaultFuture

java.lang.Object
  extended by net.sf.cindy.session.DefaultFuture
All Implemented Interfaces:
Future

public class DefaultFuture
extends java.lang.Object
implements Future

Default future implementation.

Version:
$id$
Author:
Roger Chen

Constructor Summary
DefaultFuture(Session session)
           
DefaultFuture(Session session, boolean succeeded)
           
 
Method Summary
 void addListener(FutureListener listener)
          Add future listener.
protected  void caughtException(java.lang.Throwable throwable)
           
 boolean complete()
          Waits if necessary for the task to complete.
 boolean complete(int timeout)
          Waits if necessary for the task to complete or the timeout period has expired.
 Session getSession()
          Get session associated with the future.
 boolean isCompleted()
          Return true if the task completed.
 boolean isSucceeded()
          Return true if the task completed successful.
 void removeListener(FutureListener listener)
          Remove future listener.
 void setSucceeded(boolean succeeded)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultFuture

public DefaultFuture(Session session)

DefaultFuture

public DefaultFuture(Session session,
                     boolean succeeded)
Method Detail

getSession

public Session getSession()
Description copied from interface: Future
Get session associated with the future.

Specified by:
getSession in interface Future
Returns:
session

caughtException

protected void caughtException(java.lang.Throwable throwable)

addListener

public void addListener(FutureListener listener)
Description copied from interface: Future
Add future listener.

Specified by:
addListener in interface Future
Parameters:
listener - future listener

removeListener

public void removeListener(FutureListener listener)
Description copied from interface: Future
Remove future listener.

Specified by:
removeListener in interface Future
Parameters:
listener - future listener

complete

public boolean complete()
Description copied from interface: Future
Waits if necessary for the task to complete. Warn: Block operate may lead to artificially low throughput.

Specified by:
complete in interface Future
Returns:
is succeeded

complete

public boolean complete(int timeout)
Description copied from interface: Future
Waits if necessary for the task to complete or the timeout period has expired. Warn: Block operate may lead to artificially low throughput.

Specified by:
complete in interface Future
Parameters:
timeout - timeout
Returns:
is completed

isCompleted

public boolean isCompleted()
Description copied from interface: Future
Return true if the task completed.

Specified by:
isCompleted in interface Future
Returns:
is completed

isSucceeded

public boolean isSucceeded()
Description copied from interface: Future
Return true if the task completed successful.

Specified by:
isSucceeded in interface Future
Returns:
is succeeded

setSucceeded

public void setSucceeded(boolean succeeded)