|
|
A SelectorList provides an entity where callbacks for pending I/O operations on file descriptors may be registered. The callbacks are invoked when one of the wait_and_dispatch methods is called and I/O is pending on the particular descriptors.
SelectorList (ClockBase* clock)
| SelectorList |
~SelectorList ()
| ~SelectorList |
[virtual]
bool add_ioevent_cb (XorpFd fd,
IoEventType type,
const IoEventCb& cb,
int priority = XorpTask::PRIORITY_DEFAULT)
| add_ioevent_cb |
Add a hook for pending I/O operations on a callback.
Only one callback may be registered for each possible I/O event type (read, write, exception).
Multiple event types may share the same callback. If multiple event types share the same callback and multiple types of event are pending, the callback is invoked just once and the mask argument to the callback shows which events are pending.
Parameters:
file | descriptor. |
mask | mask of I/O event types that should invoke callback. An OR'ed combination of the available SelectorMask values. |
scb | callback object that will be invoked when the descriptor. |
Returns: true if function succeeds, false otherwise.
void remove_ioevent_cb (XorpFd fd, IoEventType type = IOT_ANY)
| remove_ioevent_cb |
Remove hooks for pending I/O operations.
Parameters:
fd | the file descriptor. |
mask | of event types to be removed, e.g. an OR'ed combination of the available SelectorMask values. |
bool ready ()
| ready |
Find out if any of the selectors are ready.
Returns: true if any selector is ready.
int get_ready_priority ()
| get_ready_priority |
Find out the highest priority from the ready file descriptors.
Returns: the priority of the highest priority ready file descriptor.
int wait_and_dispatch (TimeVal& timeout)
| wait_and_dispatch |
Wait for a pending I/O events and invoke callbacks when they become ready.
Parameters:
timeout | the maximum period to wait for. |
Returns: the number of callbacks that were made.
int wait_and_dispatch (int millisecs)
| wait_and_dispatch |
Wait for a pending I/O events and invoke callbacks when they become ready.
Parameters:
millisecs | the maximum period in milliseconds to wait for. |
Returns: the number of callbacks that were made.
size_t descriptor_count ()
| descriptor_count |
[const]
Get the count of the descriptors that have been added.
Returns: the count of the descriptors that have been added.
void get_fd_set (SelectorMask selected_mask, fd_set& fds)
| get_fd_set |
[const]
Get a copy of the current list of monitored file descriptors in Unix fd_set format
Parameters:
the | selected mask as SelectorMask (SEL_RD, SEL_WR, or SEL_EX) |
Returns: the selected fd_set.
int get_max_fd ()
| get_max_fd |
[const]
Get a the value of the largest monitored file descriptor
Returns: the maximum fd.
void set_observer (SelectorListObserverBase& obs)
| set_observer |
Set the SelectorObserver object that will receive notifications
Returns: void
void remove_observer ()
| remove_observer |
Remove the SelectorObserver object that receives notifications
Returns: void
void callback_bad_descriptors ()
| callback_bad_descriptors |
[protected]