org.otfeed
Interface IRequest

All Known Implementing Classes:
OptionChainWithSnapshotRequest, TickStreamWithSnapshotRequest

public interface IRequest

Defines contract for the Request handler. Instance of IRequest is returned by IConnection.prepareRequest(org.otfeed.protocol.ICommand) metod.

Use this handle to actually submit() the asynchronous request, to cancel() it or to block till request is complete.

Implementations must be thread-safe. All implementation supplied by org.otfeed are thread-safe.


Method Summary
 void cancel()
          Cancels the request.
 OTError getError()
          Returns error.
 boolean isCompleted()
          Returns request completion status.
 void submit()
          Submits the request.
 void waitForCompletion()
          Waits for request to complete (indefinetely).
 boolean waitForCompletion(long millis)
          Waits for request to complete.
 

Method Detail

submit

void submit()
Submits the request. If request is already active, does nothing.


cancel

void cancel()
Cancels the request. If request is not active, does nothing.


isCompleted

boolean isCompleted()
Returns request completion status. After request is completed, one may want to check error property to see whether completion was normal or an error has occured.

Returns:
true if request has completed, false otherwise.

getError

OTError getError()
Returns error. If request is still running, or has completed normally, returns null.

Returns:
error.

waitForCompletion

boolean waitForCompletion(long millis)
Waits for request to complete.

Parameters:
millis - timeout value in millis.
Returns:
true if request completed or has been successfully cancelled, false on timeout.

waitForCompletion

void waitForCompletion()
Waits for request to complete (indefinetely).



Copyright © 2007 Mike Kroutikov. All Rights Reserved.