class Poller_sigio

A class to monitor a set of file descriptors for readiness events.

Inheritance:


Public Methods

[more]virtual int setSignum(int signum)
Tell the Poller which signal number to use.
[more]int init()
Initialize the Poller
[more]void shutdown()
Release any resouces allocated internally by this Poller
[more]virtual int add(int fd, Client* client, short eventmask)
Add a file descriptor to the set we monitor.
[more]virtual int del(int fd)
Remove a file descriptor
[more]virtual int setMask(int fd, short eventmask)
Give a new value for the given file descriptor's eventmask
[more]virtual int orMask(int fd, short eventmask)
Set fd's eventmask to its present value OR'd with the given one
[more]virtual int andMask(int fd, short eventmask)
Set fd's eventmask to its present value AND'd with the given one
[more]virtual void clearReadiness(int fd, short eventmask)
Reset the given readiness bits.
[more]virtual int waitForEvents(int timeout_millisec)
Sleep at most timeout_millisec waiting for an I/O readiness event on the file descriptors we're watching.
[more]virtual int getNextEvent(PollEvent* e)
Get the next event that was found by waitForEvents.
[more]virtual 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

oint initWakeUpPipe()
oint wakeUp()

Public Members

ostruct 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. This implementation is a wrapper around the F_SETSIG event delivery scheme provided by Linux.

Warning: the 2.4 linux kernel works fine with all parts of this class except wakeUp(). The 2.4 linux kernel does not by default support using SIGIO with pipes. See Jeremy Elson's patch, http://www.cs.helsinki.fi/linux/linux-kernel/2002-13/0191.html if you want to use this class with pipes, or if you want to use the wakeUp method of this class.

ovirtual int setSignum(int signum)
Tell the Poller which signal number to use. Call once after init(), before add().

oint init()
Initialize the Poller

ovoid shutdown()
Release any resouces allocated internally by this Poller

ovirtual int add(int fd, Client* client, short eventmask)
Add a file descriptor to the set we monitor. Caller should already have established a handler for SIGIO.
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

ovirtual int del(int fd)
Remove a file descriptor

ovirtual int setMask(int fd, short eventmask)
Give a new value for the given file descriptor's eventmask

ovirtual int orMask(int fd, short eventmask)
Set fd's eventmask to its present value OR'd with the given one

ovirtual int andMask(int fd, short eventmask)
Set fd's eventmask to its present value AND'd with the given one

ovirtual void clearReadiness(int fd, short eventmask)
Reset the given readiness bits. Do this after you finish handling an event and don't want to be notified about it again until the OS says it's newly ready. This does nothing except in one-shot notification schemes like Poller_sigio.

ovirtual 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

ovirtual int getNextEvent(PollEvent* e)
Get the next event that was found by waitForEvents.
Returns:
0 on success, EWOULDBLOCK if no more events

ovirtual 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.

oClient* m_client
Who's interested in this fd

oint m_next
Index of the next fdstate in the list, or -1

oint m_prev
Index of the previous fdstate in the list, or -1

oshort m_mask
What poll bits the caller is interested in for this fd

oshort m_readybits
What operations the fd is currently ready for


Direct child classes:
Poller_sigfd

Alphabetic index HTML hierarchy of classes or Java



This page was generated with the help of DOC++.