|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object seda.sandStorm.lib.aSocket.nbio.SelectSource
public class SelectSource
A SelectSource is an implementation of SourceIF which pulls events from the operating system via the NBIO SelectSet interface. This can be thought of as a 'shim' which turns a SelectSet into a SourceIF.
SelectSource can also "balances" the set of events returned on subsequent calls to dequeue, in order to avoid biasing the servicing of underlying O/S events to a particular order. This feature can be disabled by creating a SelectSource with the boolean flag 'do_balance'.
Field Summary | |
---|---|
private int[] |
balancer_seq
|
private int |
balancer_seq_off
|
private int |
BALANCER_SEQUENCE_SIZE
|
private java.lang.Object |
blocker
|
private static boolean |
DEBUG
|
private boolean |
do_balance
|
private seda.nbio.SelectItem[] |
ready
|
private int |
ready_offset
|
private int |
ready_size
|
private seda.nbio.SelectSet |
selset
|
Constructor Summary | |
---|---|
SelectSource()
Create a new empty SelectSource. |
|
SelectSource(boolean do_balance)
Create a new empty SelectSource. |
Method Summary | |
---|---|
private void |
balance(seda.nbio.SelectItem[] selarr)
|
QueueElementIF[] |
blocking_dequeue_all(int timeout_millis)
Dequeue a set of elements from the SelectSource. |
QueueElementIF |
blocking_dequeue(int timeout_millis)
Dequeue the next element from the SelectSource. |
QueueElementIF[] |
blocking_dequeue(int timeout_millis,
int num)
Dequeue a set of elements from the SelectSource. |
QueueElementIF[] |
dequeue_all()
Dequeues all elements which are ready from the SelectSource. |
QueueElementIF |
dequeue()
Dequeues the next element from the SelectSource without blocking. |
QueueElementIF[] |
dequeue(int num)
Dequeues at most num elements which are ready from the SelectSource. |
void |
deregister(java.lang.Object selobj)
Deregister a SelectItem with this SelectSource. |
private void |
doPoll(int timeout)
|
java.lang.Object |
getSelectSet()
|
private void |
initBalancer()
|
int |
numActive()
Return the number of active SelectItems registered with the SelectSource. |
int |
numRegistered()
Return the number of SelectItems registered with the SelectSource. |
void |
register(java.lang.Object selobj)
Register a SelectItem with the SelectSource. |
java.lang.Object |
register(java.lang.Object sc_obj,
int ops)
|
int |
size()
Return the number of elements waiting in the queue (that is, which don't require a SelectSet poll operation to retrieve). |
void |
update()
Must be called if the 'events' mask of any SelectItem registered with this SelectSource changes. |
void |
update(java.lang.Object selobj)
Must be called if the 'events' mask of this SelectItem (which must be registered with this SelectSource) changes. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final boolean DEBUG
private seda.nbio.SelectSet selset
private seda.nbio.SelectItem[] ready
private int ready_offset
private int ready_size
private boolean do_balance
private final int BALANCER_SEQUENCE_SIZE
private int[] balancer_seq
private int balancer_seq_off
private java.lang.Object blocker
Constructor Detail |
---|
public SelectSource()
public SelectSource(boolean do_balance)
do_balance
- Indicates whether this SelectSource should perform
event balancing.Method Detail |
---|
public java.lang.Object getSelectSet()
public void register(java.lang.Object selobj)
The user is allowed to modify the event flags in the SelectItem directly (say, to cause the SelectSource ignore a given SelectItem for the purposes of future calls to one of the dequeue methods). However, modifying the event flags may not be synchronous with calls to dequeue - generally because SelectSource maintains a cache of recently-received events.
register
in interface SelectSourceIF
Selectable
public java.lang.Object register(java.lang.Object sc_obj, int ops)
register
in interface SelectSourceIF
public void deregister(java.lang.Object selobj)
deregister
in interface SelectSourceIF
public void update()
update
in interface SelectSourceIF
public void update(java.lang.Object selobj)
update
in interface SelectSourceIF
public int numRegistered()
numRegistered
in interface SelectSourceIF
public int numActive()
numActive
in interface SelectSourceIF
public int size()
size
in interface SourceIF
size
in interface SelectSourceIF
public QueueElementIF dequeue()
dequeue
in interface SourceIF
QueueElementIF
on the queuepublic QueueElementIF[] dequeue_all()
dequeue_all
in interface SourceIF
QueueElementIF
s on the queuepublic QueueElementIF[] dequeue(int num)
dequeue
in interface SourceIF
num
QueueElementIF
s on the queuepublic QueueElementIF blocking_dequeue(int timeout_millis)
blocking_dequeue
in interface SourceIF
public QueueElementIF[] blocking_dequeue_all(int timeout_millis)
blocking_dequeue_all
in interface SourceIF
timeout_millis
- if timeout_millis is 0
, this method
will be non-blocking and will return right away, whether or not
any elements are pending on the queue. If timeout_millis is
-1
, this method blocks forever until something is
available. If timeout_millis is positive, this method will wait
about that number of milliseconds before returning, but possibly a
little more.
QueueElementIF
's. This array will
be null if no elements were pending.public QueueElementIF[] blocking_dequeue(int timeout_millis, int num)
blocking_dequeue
in interface SourceIF
private void doPoll(int timeout)
private void balance(seda.nbio.SelectItem[] selarr)
private void initBalancer()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |