com.sun.sgs.nio.channels
Interface CompletionHandler<R,A>

Type Parameters:
R - the result type
A - the attachment type
All Known Implementing Classes:
DelegatingCompletionHandler

public interface CompletionHandler<R,A>

A handler for consuming the result of an asynchronous operation.

The asynchronous channels defined in this package allow a completion handler to be specified to consume the result of an asynchronous operation. When an operation completes the handler's completed method is invoked with the result.

Usage Example

    InetSocketAddress addr = ...
    AsynchronousSocketChannel ch = AsynchronousSocketChannel.open();
 
    ch.connect(addr, new CompletionHandler<Void,Void>() {
        public void completed(IoFuture<Void,Void> result) {
            try {  
                result.getNow();
                // connection established
 
            } catch (ExecutionException x) { 
                ...
            }
        }
    });
 


Method Summary
 void completed(IoFuture<R,A> result)
          Invoked when an operation has completed.
 

Method Detail

completed

void completed(IoFuture<R,A> result)
Invoked when an operation has completed.

The result parameter is an IoFuture representing the result of the operation. Its getNow method should be invoked to retrieve the result.

This method should complete in a timely manner so as to avoid keeping this thread from dispatching to other completion handlers.

Parameters:
result - the IoFuture representing the result of the operation

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