A class to monitor a set of file descriptors for readiness events.
Inheritance:
Public Methods
-
int init()
- Initialize the Poller
-
void shutdown()
- Release any resouces allocated internally by this Poller
-
int add(int fd, Client* client, short eventmask)
- Add a file descriptor to the set we monitor.
-
int del(int fd)
- Remove a file descriptor
-
int setMask(int fd, short eventmask)
- Give a new value for the given file descriptor's eventmask
-
int orMask(int fd, short eventmask)
- Set fd's eventmask to its present value OR'd with the given one
-
int andMask(int fd, short eventmask)
- Set fd's eventmask to its present value AND'd with the given one
-
int waitForEvents(int timeout_millisec)
- Sleep at most timeout_millisec waiting for an I/O readiness event on the file descriptors we're watching.
-
int getNextEvent(PollEvent* e)
- Get the next event that was found by waitForEvents.
-
int waitAndDispatchEvents(int timeout_millisec)
- Sleep at most timeout_millisec waiting for an I/O readiness event on the file descriptors we're watching, and dispatch events to the handler for each file descriptor that is ready for I/O.
Inherited from Poller:
Public Methods
-
virtual int setSignum(int signum)
-
virtual void clearReadiness(int fd, short eventmask)
-
int initWakeUpPipe()
-
int wakeUp()
Public Members
-
struct PollEvent
-
class Client
- A class to handle a particular file descriptor's readiness events
Documentation
A class to monitor a set of file descriptors for readiness events.
Current an efficient wrapper around the poll() system call.
This is the code you would have written yourself if you had had the time...
- int init()
- Initialize the Poller
- void shutdown()
- Release any resouces allocated internally by this Poller
- int add(int fd, Client* client, short eventmask)
-
Add a file descriptor to the set we monitor.
- Parameters:
- - fd file descriptor to add
- client object to handle events for this fd. May use same client with more than one fd.
eventmask - initial event mask for this fd
- int del(int fd)
- Remove a file descriptor
- int setMask(int fd, short eventmask)
- Give a new value for the given file descriptor's eventmask
- int orMask(int fd, short eventmask)
- Set fd's eventmask to its present value OR'd with the given one
- int andMask(int fd, short eventmask)
- Set fd's eventmask to its present value AND'd with the given one
- int waitForEvents(int timeout_millisec)
-
Sleep at most timeout_millisec waiting for an I/O readiness event
on the file descriptors we're watching. Fills internal array
of readiness events. Call getNextEvent() repeatedly to read its
contents.
- Returns:
- 0 on success, EWOULDBLOCK if no events ready
- int getNextEvent(PollEvent* e)
-
Get the next event that was found by waitForEvents.
- Returns:
- 0 on success, EWOULDBLOCK if no more events
- int waitAndDispatchEvents(int timeout_millisec)
-
Sleep at most timeout_millisec waiting for an I/O readiness event
on the file descriptors we're watching, and dispatch events to
the handler for each file descriptor that is ready for I/O.
This is included as an example of how to use
waitForEvents and getNextEvent. Real programs should probably
avoid waitAndDispatchEvents and call waitForEvents and getNextEvent
instead for maximum control over client deletion.
- This class has no child classes.
Alphabetic index HTML hierarchy of classes or Java
This page was generated with the help of DOC++.