net.sf.asyncobjects.net.nio
Class NIOSelectorVat

java.lang.Object
  extended by net.sf.asyncobjects.vats.Vat
      extended by net.sf.asyncobjects.net.nio.NIOSelectorVat

public class NIOSelectorVat
extends Vat

This is a vat that uses NIO services provided by NIOSelectorRunner. The vat support detaching and ataching to such runners. Currently detach is not supported for this vat.

Author:
const

Nested Class Summary
 
Nested classes/interfaces inherited from class net.sf.asyncobjects.vats.Vat
Vat.VatState
 
Field Summary
 
Fields inherited from class net.sf.asyncobjects.vats.Vat
attachmentLock, detach, state, stateLock, ticket
 
Constructor Summary
NIOSelectorVat(NIOSelectorRunner runner, String name)
          A constructor
 
Method Summary
 void detachFromRunner(boolean waitForIt)
          Detach from runner.
 SelectionKey registerChannel(SelectableChannel ch)
          register channel with listener
 NIOSelectorRunner runner()
           
 Promise<Void> waitAcceptable(SelectionKey key)
          wait until socket will became acceptable
 Promise<Void> waitConnectable(SelectionKey key)
          wait until socket will became ready to finish connection
 Promise<Void> waitReadable(SelectionKey key)
          wait until socket will became readable
 Promise<Void> waitWritable(SelectionKey key)
          wait until socket will became writable
 
Methods inherited from class net.sf.asyncobjects.vats.Vat
attachToRunner, current, dispatchEventBatch, dispatchVatEvents, enqueue, generateVatName, getName, getRunner, hasEvents, isDetached, offerSensor, resetCurrentVat, setCurrentVat
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NIOSelectorVat

public NIOSelectorVat(NIOSelectorRunner runner,
                      String name)
A constructor

Parameters:
runner - a runner
name - a name of vat
Method Detail

detachFromRunner

public void detachFromRunner(boolean waitForIt)
                      throws InterruptedException
Description copied from class: Vat
Detach from runner.

Overrides:
detachFromRunner in class Vat
Parameters:
waitForIt - if true, the method does not returns until vat
Throws:
InterruptedException - operation was interrupted, detach process is possibly incomplete
See Also:
Vat.detachFromRunner(boolean)

registerChannel

public SelectionKey registerChannel(SelectableChannel ch)
                             throws Exception
register channel with listener

Parameters:
ch - a channel used by component
Returns:
a selection key for that component
Throws:
Exception - if there is IO problme

runner

public NIOSelectorRunner runner()
Overrides:
runner in class Vat
Returns:
runner for the current vat
See Also:
Vat.runner()

waitAcceptable

public Promise<Void> waitAcceptable(SelectionKey key)
wait until socket will became acceptable

Parameters:
key - to wait on
Returns:
promise for operation

waitReadable

public Promise<Void> waitReadable(SelectionKey key)
wait until socket will became readable

Parameters:
key - to wait on
Returns:
promise for operation

waitWritable

public Promise<Void> waitWritable(SelectionKey key)
wait until socket will became writable

Parameters:
key - to wait on
Returns:
promise for operation

waitConnectable

public Promise<Void> waitConnectable(SelectionKey key)
wait until socket will became ready to finish connection

Parameters:
key - to wait on
Returns:
promise for operation


Copyright © 2002-2007 Constantine Plotnikov. All Rights Reserved.