Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 0bdbf371f93662c8f0deeff7a1d29166 > files > 9

cheops-ng-0.2.3-5mdv2010.0.i586.rpm

IO management routines are locate in io.c and io.h.  The cheops backend
centers around a poll() call on a set (possibly a large number) of file
descriptors.  cheops_io_add, cheops_io_change, and cheops_io_remove are
used to manipulate this list.  Operating systems which do not support poll
may use some sort of select() emulation.  Cheops is designed to take
advantage of this powerful system.

IO management is complicated by the fact that poll requires an array as
its primary argument and provides no callback field.  Therefore, our data
is basically stored in a parallel array, with the same index.  The ID
number of the I/O event is then index into these arrays. 

This does present a problem because of removing entries.  That will tend
to leave holes in the poll() array which can be filled by re-arranging
the existing entries.  This, however, redefines the ID numbers, so for all
manipulation, we use pointers to the ID numbers instead of actual
integers.  Using this double indirection method, all operations remain
O(1), including delete!