This is a monkey patch I designed to augment Eventmachine's simple but ineffective threadpooling.
Implemented:
A monitoring thread that maintains the health of the threadpool.
An EM based mechanism to timeout threads safely by raising an exception
The ability to dynamically increase or decrease the size of the pool.
A simple carry to allow you to pass data between the caller and the callback.
Planned
A more general signaling mechanism. Canceling of jobs should be available as soon as I have time to delve inside the implementation of the Thread Queue class (which is curiously devoid of any instance variables....)
To Do:
Figure out some comprehensive tests
Research a way to avoid the use of Thread.exclusive
The goodness is handled by a call to EM.schedule which transparently sets up the scheduler if necessary. Pass in a lambda and set the callback for the result, errback to work with exceptions if execution goes awry, and hash options. Current thread options include timeout to kill a thread if it hangs too long and carry which allows the caller to pass independent information to the callback.