cz.cuni.amis.utils.future
Class RunnableFuture<RESULT>

Package class diagram package RunnableFuture
java.lang.Object
  extended by cz.cuni.amis.utils.future.RunnableFuture<RESULT>
All Implemented Interfaces:
IFuture<RESULT>, Runnable, Future<RESULT>

public abstract class RunnableFuture<RESULT>
extends Object
implements Runnable, IFuture<RESULT>


Constructor Summary
RunnableFuture()
           
 
Method Summary
 boolean cancel(boolean mayInterruptIfRunning)
           
 RESULT get()
          Waits if necessary for the computation to complete, and then retrieves its result.
 RESULT get(long timeout, TimeUnit unit)
          Waits if necessary for at most the given time for the computation to complete, and then retrieves its result, if available.
 boolean isCancelled()
           
 boolean isDone()
           
protected abstract  RESULT process()
          Provide the implementation of your work that returns some RESULT or throws an exception if something happens.
 void run()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RunnableFuture

public RunnableFuture()
Method Detail

process

protected abstract RESULT process()
                           throws Exception
Provide the implementation of your work that returns some RESULT or throws an exception if something happens.

Returns:
Throws:
Exception

run

public final void run()
Specified by:
run in interface Runnable

cancel

public final boolean cancel(boolean mayInterruptIfRunning)
Specified by:
cancel in interface Future<RESULT>

get

public final RESULT get()
Description copied from interface: IFuture
Waits if necessary for the computation to complete, and then retrieves its result.

Specified by:
get in interface IFuture<RESULT>
Specified by:
get in interface Future<RESULT>
Returns:
the computed result

get

public final RESULT get(long timeout,
                        TimeUnit unit)
                 throws PogamutInterruptedException,
                        PogamutTimeoutException
Description copied from interface: IFuture
Waits if necessary for at most the given time for the computation to complete, and then retrieves its result, if available.

Specified by:
get in interface IFuture<RESULT>
Specified by:
get in interface Future<RESULT>
Parameters:
timeout - the maximum time to wait
unit - the time unit of the timeout argument
Returns:
the computed result
Throws:
PogamutInterruptedException - if the current thread was interrupted while waiting
PogamutTimeoutException - if the wait timed out

isCancelled

public final boolean isCancelled()
Specified by:
isCancelled in interface Future<RESULT>

isDone

public final boolean isDone()
Specified by:
isDone in interface Future<RESULT>


Copyright © 2012 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.