Is there a way to execute a function or have a child thread notify the parent thread when it completes its job or terminates gracefully in C++?

Viewed 35

I am designing a multi-threaded producer consumer system where the consumer takes in requests from the producer and processes each request in a separate thread. An available thread would get picked up from a fixed size thread pool when a request is received. The request would get added to a queue in case all threads were busy and as the threads get freed up from their assigned tasks, they pick up the request on a FIFO basis from the queue.

I am looking for a way where the child thread can notify the parent thread upon completion of its job, without the parent thread getting blocked by doing a 'join' on the child thread.

0 Answers
Related