Extend ThreadWrapper for scalable shutdown in a collection.
Status: Beta
Brought to you by:
jmmcg
A collection of ThreadWrappers in a collection suffers a serialized destruction of the threads. To shut them down in parallel:
1. Add a template param. to the ThreadWrapper: ..., typename ExitEventT ExitEvent = Event, ... (Makes it work as before.)
2. Create a template class ThreadPool that takes the ThreadWrapper-derived class as a template param. & the collection type. Also has members:
Event ExitRequest;
colln_type< ThWr<...., &ExitRequest, ...> > colln;
~ThreadPool() {
ExitRequest.set();
}
3. Ensure ThreadWrapper-derived class declared with "Event *" for ExitEventT template param.