org.xsocket
Interface IDispatcher<T extends IHandle>

Package class diagram package IDispatcher
All Superinterfaces:
java.io.Closeable, java.lang.Runnable
All Known Implementing Classes:
Dispatcher

public interface IDispatcher<T extends IHandle>
extends java.lang.Runnable, java.io.Closeable

A Dispatcher encapsulates an underlying Selector. It is responsible for the channel handle management. If a readiness event occurs, the assigned IEventHandler will be called.


Method Summary
 void deregister(T handle)
          deregister a handle.
 IEventHandler<T> getEventHandler()
          get the event handler of this dispatcher

.
 long getNumberOfHandledReads()
          get the number of handled reads
 long getNumberOfHandledRegistrations()
          get the number of handled registractions
 long getNumberOfHandledWrites()
          get the number of handled writes
 java.util.Set<T> getRegistered()
          return the registered handles
 void register(T handle, int ops)
          register a new handle.
 void updateInterestSet(T handle, int ops)
          announce a write for he given handle.
 
Methods inherited from interface java.lang.Runnable
run
 
Methods inherited from interface java.io.Closeable
close
 

Method Detail

getEventHandler

IEventHandler<T> getEventHandler()
get the event handler of this dispatcher

. This method is thread save

Returns:
the event handler

register

void register(T handle,
              int ops)
              throws java.io.IOException
register a new handle.

. This method is thread save

Parameters:
handle - the handle to register
ops - the interest set
Throws:
java.io.IOException - If some I/O error occurs

deregister

void deregister(T handle)
                throws java.io.IOException
deregister a handle.

This method is thread save

Parameters:
handle - the handle to deregister
Throws:
java.io.IOException - If some I/O error occurs

getRegistered

java.util.Set<T> getRegistered()
return the registered handles

Returns:
a list of the registered handles

updateInterestSet

void updateInterestSet(T handle,
                       int ops)
                       throws java.io.IOException
announce a write for he given handle.

This method is thread save

Parameters:
handle - the handle for the write need
ops - the interest set
Throws:
java.io.IOException - if the given hnadle is invalid

getNumberOfHandledRegistrations

long getNumberOfHandledRegistrations()
get the number of handled registractions

Returns:
the number of handled registractions

getNumberOfHandledReads

long getNumberOfHandledReads()
get the number of handled reads

Returns:
the number of handled reads

getNumberOfHandledWrites

long getNumberOfHandledWrites()
get the number of handled writes

Returns:
the number of handled writes