in reply to Dormus interruptus
I'm no expert in threads, so there's a chance this suggestion is naive and broken. I'd like to hear about it in that case :)
What you could do is make scheduling the responsibility of the parent thread, and communicate actions to the workers through separate queues (that is, a single Thread::Queue per thread).
Each worker thread never sleeps; instead, it performs a blocking dequeue and receives one of two messages: work, or quit. In the latter case it just calls join. In the former it does its worker job.
This approach means that your server needs to contain explicit scheduling code, and a way to immediately receive keyboard events despite that.
|
---|