com.sun.sgs.impl.nio
Class Reactor.PendingOperation

java.lang.Object
  extended by com.sun.sgs.impl.nio.Reactor.PendingOperation
Enclosing class:
Reactor

abstract class Reactor.PendingOperation
extends Object

Manages a single asynchronous IO operation for a Reactor.ReactiveAsyncKey. Behaves appropriately when no operation is pending, or when a race occurs between, e.g., timeout and user cancellation.


Field Summary
protected  AtomicReference<Reactor.AsyncOp<?>> task
          The continuation of the IO task to perform, if one is pending, or a reference to null if an operation is not pending.
 
Constructor Summary
Reactor.PendingOperation(Reactor.ReactiveAsyncKey asyncKey, int op)
          Creates a new instance to manage the given operation for the given key.
 
Method Summary
(package private)  void cleanupTask()
          Marks the operation as no-longer-pending, and cancels the timeout expiration action for the task, if any.
(package private)
<R,A> IoFuture<R,A>
execute(A attachment, CompletionHandler<R,? super A> handler, long timeout, TimeUnit unit, Callable<R> callable)
          Attempts to initiate an asynchronous operation.
(package private)  boolean isPending()
          Returns true if this operation is pending, otherwise false.
protected abstract  void pendingPolicy()
          Overridden by subclasses to take the appropriate action when an attempt is made to invoke this operation while it is already pending.
(package private)  void selected()
          Runs the pending operation, if any.
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

task

protected final AtomicReference<Reactor.AsyncOp<?>> task
The continuation of the IO task to perform, if one is pending, or a reference to null if an operation is not pending.

Constructor Detail

Reactor.PendingOperation

Reactor.PendingOperation(Reactor.ReactiveAsyncKey asyncKey,
                         int op)
Creates a new instance to manage the given operation for the given key.

Parameters:
asyncKey - the async key
op - the operation to manage
Method Detail

pendingPolicy

protected abstract void pendingPolicy()
Overridden by subclasses to take the appropriate action when an attempt is made to invoke this operation while it is already pending.

This method must always throw an unchecked exception.


selected

void selected()
Runs the pending operation, if any.

See Also:
AsyncKey.selected(int)

isPending

boolean isPending()
Returns true if this operation is pending, otherwise false.

Returns:
true if this operation is pending, otherwise false
See Also:
AsyncKey.isOpPending(int)

cleanupTask

void cleanupTask()
Marks the operation as no-longer-pending, and cancels the timeout expiration action for the task, if any.


execute

<R,A> IoFuture<R,A> execute(A attachment,
                            CompletionHandler<R,? super A> handler,
                            long timeout,
                            TimeUnit unit,
                            Callable<R> callable)
Attempts to initiate an asynchronous operation. If an operation is already pending, an appropriate exception is thrown by a subclass via its pendingPolicy().

Type Parameters:
R - the result type
A - the attachment type
Parameters:
attachment - the attachment for the completion handler; may be null
handler - the completion handler; may be null
timeout - the timeout, or 0 indicating no timeout
unit - the unit of the timeout
callable - the IO action to perform when this operation is ready
Returns:
an IoFuture representing the pending operation
See Also:
AsyncKey.execute(int, Object, CompletionHandler, long, TimeUnit, Callable)

toString

public String toString()

Overrides:
toString in class Object

RedDwarf, Version 0.10.1
2010-03-14 10:56:12

Copyright © 2010 The RedDwarf Authors. All rights reserved
Copyright © 2007-2010 Sun Microsystems, Inc. All rights reserved