Thread Scheduler with I/O
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.
socket.select function of LuaSocket package) to select I/O channels ready for access.
Executes the same initialization of its superclass
Schedulerwith value provided by
objectand additionally creates the lists used to map channels to blocked threads (i.e.
Function that implements the same API of
socket.selectfunction of LuaSocket package but can select channels of any type supported by the
- 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
coroutinefrom the lists of I/O blocked threads.
Redefinition of superclass method in order to check if the registering
coroutineis 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.
- This class was mainly devised for use with the asynchronous support provided by LuaSocket library for socket channels. Therefore, it may not cope very well with other asynchronous I/O libraries.
This class is not very scalable nor efficient due to constrains imposed by LuaSocket API.
Mainly due to the