org.atmosphere.wasync.impl
Class DefaultFuture

java.lang.Object
  extended by org.atmosphere.wasync.impl.DefaultFuture
All Implemented Interfaces:
java.util.concurrent.Future<Socket>

public class DefaultFuture
extends java.lang.Object
implements Future

The default Future used by the library, based on the CountDownLatch

Author:
Jeanfrancois Arcand

Constructor Summary
DefaultFuture(DefaultSocket socket)
           
 
Method Summary
 boolean cancel(boolean mayInterruptIfRunning)
          
 void close()
          Close the underlying Socket
 void done()
          Mark this instance as done.
 Future finishOrThrowException()
          Mark the future done.
 Future fire(java.lang.Object data)
          Send data to the remote Server.
 Socket get()
          
 Socket get(long timeout, java.util.concurrent.TimeUnit unit)
          
 Future ioException(java.io.IOException t)
          If an exception occurs, the Transport will set it using this method.
 boolean isCancelled()
          
 boolean isDone()
          
protected  void reset()
           
protected  Socket socket()
           
 long time()
           
 DefaultFuture timeoutException(java.util.concurrent.TimeoutException te)
           
 java.util.concurrent.TimeUnit timeUnit()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultFuture

public DefaultFuture(DefaultSocket socket)
Method Detail

time

public long time()

timeUnit

public java.util.concurrent.TimeUnit timeUnit()

timeoutException

public DefaultFuture timeoutException(java.util.concurrent.TimeoutException te)

cancel

public boolean cancel(boolean mayInterruptIfRunning)

Specified by:
cancel in interface java.util.concurrent.Future<Socket>

isCancelled

public boolean isCancelled()

Specified by:
isCancelled in interface java.util.concurrent.Future<Socket>

isDone

public boolean isDone()

Specified by:
isDone in interface java.util.concurrent.Future<Socket>

done

public void done()
Description copied from interface: Future
Mark this instance as done.


close

public void close()
Description copied from interface: Future
Close the underlying Socket


finishOrThrowException

public Future finishOrThrowException()
                              throws java.io.IOException
Mark the future done. If an exception occurred, this method will throw it.

Returns:
a Future
Throws:
java.io.IOException

ioException

public Future ioException(java.io.IOException t)
If an exception occurs, the Transport will set it using this method. An application can also use that method to interrupt a blocking Socket.open(Request) operation. This operation must unlock the current blocked thread.

Parameters:
t - a IOException
Returns:
a Future

reset

protected void reset()

get

public Socket get()
           throws java.lang.InterruptedException,
                  java.util.concurrent.ExecutionException

Specified by:
get in interface java.util.concurrent.Future<Socket>
Throws:
java.lang.InterruptedException
java.util.concurrent.ExecutionException

get

public Socket get(long timeout,
                  java.util.concurrent.TimeUnit unit)
           throws java.lang.InterruptedException,
                  java.util.concurrent.ExecutionException,
                  java.util.concurrent.TimeoutException

Specified by:
get in interface java.util.concurrent.Future<Socket>
Throws:
java.lang.InterruptedException
java.util.concurrent.ExecutionException
java.util.concurrent.TimeoutException

socket

protected Socket socket()

fire

public Future fire(java.lang.Object data)
            throws java.io.IOException
Send data to the remote Server.

Parameters:
data - the message to fire
Returns:
a Future
Throws:
java.io.IOException


Copyright © 2014. All Rights Reserved.