ThreadPool thread available event #4609
cooopermaira
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have added a heap allocated Poco::Event with autoreset = true as a member variable in the threadpool. When the threadpool spawns a pooled thread, it passes a reference to this event. Then, at the end of PooledThread.run() right after _targetCompleted.set() I also signal this ThreadPool owned event. This way, when a job queue that owns a threadpool checks ThreadPool->available() and finds no threads are available it can then execute ThreadPool->thisEvent.wait() and will be notified when a thread becomes available so that it can launch a new job on the pool. In this way, a job queue manager doesn't have to continuously probe threadpool->available().
What do you think? Is this feature worth integrating?
Beta Was this translation helpful? Give feedback.
All reactions