More information: http://www.cs.berkeley.edu/~mdw/proj/seda/

seda.nbio
Class SelectSetDevPollImpl

java.lang.Object
  |
  +--seda.nbio.SelectSetImpl
        |
        +--seda.nbio.SelectSetDevPollImpl

class SelectSetDevPollImpl
extends SelectSetImpl

SelectSetDevPollImpl is an implementation of SelectSet which uses the UNIX /dev/poll mechanism.

See Also:
SelectSet

Constructor Summary
(package private) SelectSetDevPollImpl()
          Create a SelectSetDevPollImpl with no SelectItems.
 
Method Summary
(package private)  void add(SelectItem sel)
          Add a SelectItem to this SelectSetDevPollImpl.
(package private)  void add(SelectItem[] selarr)
          Add all of the SelectItems in the given array to the SelectSetDevPollImpl.
(package private)  SelectItem elementAt(int index)
          Return the SelectItem at the given index.
(package private)  SelectItem[] getEvents()
          Returns an array of SelectItems for which some events have occurred (that is, that the revents field is nonzero).
(package private)  SelectItem[] getEvents(short mask)
          Returns an array of SelectItems for which events matching the given event mask have occurred (that is, that the revents field matches the given mask).
(package private) static boolean isSupported()
          Returns true if /dev/poll is supported on this platform.
(package private)  int numActive()
          Return the number of active SelectItems in this SelectSetDevPollImpl.
(package private)  void remove(int index)
          Remove the SelectItem at the given index from the SelectSetDevPollImpl.
(package private)  void remove(SelectItem sel)
          Remove a SelectItem from the SelectSetDevPollImpl.
(package private)  void remove(SelectItem[] selarr)
          Remove all of the SelectItems in the given array from the SelectSetDevPollImpl.
(package private)  int select(int timeout)
          Wait for events to occur on the SelectItems in this SelectSetDevPollImpl.
(package private)  int size()
          Return the number of SelectItems in this SelectSetDevPollImpl.
 java.lang.String toString()
           
(package private)  void update()
          Push updated event masks for all SelectItems in this SelectSet to the /dev/poll device.
(package private)  void update(SelectItem sel)
          Push updated event masks for all SelectItems in this SelectSet to native code.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SelectSetDevPollImpl

SelectSetDevPollImpl()
Create a SelectSetDevPollImpl with no SelectItems.
Method Detail

isSupported

static boolean isSupported()
Returns true if /dev/poll is supported on this platform.

add

void add(SelectItem sel)
Add a SelectItem to this SelectSetDevPollImpl.
Overrides:
add in class SelectSetImpl

add

void add(SelectItem[] selarr)
Add all of the SelectItems in the given array to the SelectSetDevPollImpl.
Overrides:
add in class SelectSetImpl

remove

void remove(SelectItem sel)
Remove a SelectItem from the SelectSetDevPollImpl.
Overrides:
remove in class SelectSetImpl

remove

void remove(SelectItem[] selarr)
Remove all of the SelectItems in the given array from the SelectSetDevPollImpl.
Overrides:
remove in class SelectSetImpl

remove

void remove(int index)
Remove the SelectItem at the given index from the SelectSetDevPollImpl.
Overrides:
remove in class SelectSetImpl

update

void update()
Push updated event masks for all SelectItems in this SelectSet to the /dev/poll device.
Overrides:
update in class SelectSetImpl

update

void update(SelectItem sel)
Push updated event masks for all SelectItems in this SelectSet to native code.
Overrides:
update in class SelectSetImpl

size

int size()
Return the number of SelectItems in this SelectSetDevPollImpl.
Overrides:
size in class SelectSetImpl

numActive

int numActive()
Return the number of active SelectItems in this SelectSetDevPollImpl.
Overrides:
numActive in class SelectSetImpl

elementAt

SelectItem elementAt(int index)
Return the SelectItem at the given index.
Overrides:
elementAt in class SelectSetImpl

select

int select(int timeout)
Wait for events to occur on the SelectItems in this SelectSetDevPollImpl. Upon return, the 'revents' field of each SelectItem will be set to the mask of events that occurred. Note that this method does not set revents to 0 when called; after processing an event, it is the application's responsibility to clear the revents field. This is intentional: if the application wishes to delay the processing of an event, it can leave the revents field as-is so that subsequent calls to select will continue to indicate that the event is pending.

IMPORTANT NOTE: If timeout is non-zero, this call will block the thread which invokes it. If you are using Green Threads, this will block the entire JVM. Unless you have a single-threaded application, you should only use SelectSet.select() with native threads.

Overrides:
select in class SelectSetImpl
Parameters:
timeout - The maximum number of milliseconds to block waiting for an event to occur. A timeout of 0 means than select should not block; a timeout of -1 means that select should block indefinitely.
Returns:
The number of events received, or 0 if no events occurred.

getEvents

SelectItem[] getEvents(short mask)
Returns an array of SelectItems for which events matching the given event mask have occurred (that is, that the revents field matches the given mask). This is a convenience method and is not meant to be optimized; since it scans the SelectItem array and creates a new reference array, it imposes higher overhead than the application scanning the SelectItem array directly, using the size() and elementAt() methods.
Overrides:
getEvents in class SelectSetImpl

getEvents

SelectItem[] getEvents()
Returns an array of SelectItems for which some events have occurred (that is, that the revents field is nonzero). This is a convenience method and is not meant to be optimized; since it scans the SelectItem array and creates a new reference array, it imposes higher overhead than the application scanning the SelectItem array directly, using the size() and elementAt() methods.
Overrides:
getEvents in class SelectSetImpl

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

More information: http://www.cs.berkeley.edu/~mdw/proj/seda/