Author neologix
Recipients christian.heimes, felipecruz, giampaolo.rodola, gvanrossum, neologix, pitrou, rosslagerwall
Date 2013-01-05.12:40:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1357389612.59.0.680461308507.issue16853@psf.upfronthosting.co.za>
In-reply-to
Content
Here's a new version, with the following changes:
- there's no SELECT_ERR anymore: error conditions (POLLNVAL|POLLERR and also POLLHUP) are reported as SELECT_IN|SELECT_OUT, depending on the input event mask: I don't think that a separate error flag is needed, because the error will be reported when the FD will be read/written (and in the context where the error can be handled appropriately, which wouldn't be the case if an exception was thrown by the Selector). That's what Java and libevent do, for example. libevent reports IN|OUT inconditionally in case of POLLER|POLLHUP, but I think that the output events should be a subset ot input events.
- the exceptions set isn't passed to select() anymore: exception events (like OOB) are already reported in the read or write sets (checked with libevent and in the Linux kernel source)
- most importantly, there was something missing/annoying in the API: now, it only accepts only file descriptors, and also an optional opaque object: the object - called "attached data" - can be used for example to pass a callback (that can be invoked by a higher-level reactor), or for example context-specific data: it could be a kind of a thread state to make it easy to do a context-switch, or simply a high-level object like a file, a socket or a telnet instance. This is actually what Java does, but they take it further into encapsulating the FD, interested events, attached data and ready events into a SelectionKey, which is passed and returned to/from the Selector: http://docs.oracle.com/javase/7/docs/api/java/nio/channels/SelectionKey.html
- I've added some tests
History
Date User Action Args
2013-01-05 12:40:13neologixsetrecipients: + neologix, gvanrossum, pitrou, giampaolo.rodola, christian.heimes, rosslagerwall, felipecruz
2013-01-05 12:40:12neologixsetmessageid: <1357389612.59.0.680461308507.issue16853@psf.upfronthosting.co.za>
2013-01-05 12:40:12neologixlinkissue16853 messages
2013-01-05 12:40:11neologixcreate