Thread Scheduler with I/O


Subclass of Scheduler that offers support for introduction of synchronous I/O operations integrated with the scheduler. This class offers support to implement I/O operations that switch execution for other threads until the I/O channel is ready. This class is useful for implementation of I/O operations integrated with the cooperative scheduling mechanism in order to maximize the processing time.

The instances of this class have two more lists mapping I/O channels (e.g. socket or file) to the suspended threads that should be resumed when the channel becomes ready for reading or writing. Additionally, it uses a provided function (e.g. function of LuaSocket package) to select I/O channels ready for access.



Executes the same initialization of its superclass Scheduler with value provided by object and additionally creates the lists used to map channels to blocked threads (i.e. reading and writing).


select [required]
Function that implements the same API of function of LuaSocket package but can select channels of any type supported by the IOScheduler instance.
sleep [required]
Function that suspends the execution of the application for the ammount of seconds given as argument. This function called when the scheduler is idle and no thread is blocked on I/O channels.


Redefinition of superclass method in order to also remove the coroutine from the lists of I/O blocked threads.
Redefinition of superclass method in order to check if the registering coroutine is not already registered in the lists of I/O blocked threads.
Redefinition of superclass method that also unblocks waiting threads when their I/O channels are ready for access.



See class CoSocket.

Copyright (C) 2004-2008 Tecgraf, PUC-Rio

This project is currently being maintained by Tecgraf at PUC-Rio.