new poll() I/O manager
Extending MR !9676 (closed), add a new I/O manager using the new scheme. This is a low-perf portable one, based on unix poll()
.
It is mainly intended to (eventually) replace the old select()
one, and to serve as an example of the new scheme for in-RTS I/O managers.
Please ignore the first 25 patches, they're part of MR !9676 (closed), or go review them in the other MR.
Highlights of the implementation in the new I/O manager style:
- New ClosureTable module: provides a table of heap allocated objects with (optionally) stable indexes. The I/O managers can use this to keep track of in-flight async I/O operations. It's a bit like the stable pointer table, but intended to be per-capability so no locking. And it only needs a single GC root, so it's a bit more friendly to the low latency non-moving GC (spending only O(1) time rather than O(n) time during a critical phase of the GC).
- New TimeoutQueue module: it's a leftist heap, from Okasaki's book, translated from Haskell to C. All GC heap allocated. It provides O(log n) insert and delete, so can handle a much larger set of timeouts efficiently. It will also later allow for a richer timer API since it supports delete efficiently too. The same timer can be inserted and deleted many time, which will also support a nicer timer API later on.
- New StgAsyncIOOP type for tracking in-flight I/O operations. This should be usable for several I/O manager impls. It should also help us with exposing an async I/O API to Haskell.
- Later we should be able to support async I/O notification via MVars, and possibly via TVars (but that would need RTS-side support to write to a TVar).
Edited by Duncan Coutts