Event driven network I/O
The basic idea is that it should be the read/write operations that registers for select/poll/whatever notification, and not the other way around.
To do this, all I/O functions needs to be turned into asyncronous operations with completetion callbacks.
Benefits
- Much cleaner I/O event loop
- Less CPU overhead for networking I/O
- The gory details of non-blocking I/O centralized and hidden away from the protocols -> less code dupliaction
Notes
- A cbdata type should be used instead of a unix FD. This struct
contains all the gory details about current handlers, arguments, pending
I/O and such.
- The global table only contains references to the current cbdata
registered struct for a UNIX fd (i.e. lookup from UNIX fd to
"filehandle" struct)
- User supplied callback data MUST be cbdata registered
- I/O data MUST be refecence counted buffers
The reference counted buffers needs to keep
- reference count, starts at 1 when the buffer is allocated, and the buffer
is freed when the reference count reaches zero.
- amount of data currently in the buffer
- actual (allocated) size of the buffer
- the actual buffer itself
Why a cbdata type is required for the filehandle:
- if there is pending callbacks when a handle is closed
- to 100% be able to detect if the caller reuses a closed handle,
either directly or indirectly via a pending callback.
- fresh start for each new handle
$Id: design.html,v 1.1 2001/02/18 01:38:37 hno Exp $