I would like to have a worker thread wait for a command, do it, and then send the result back to the caller. This differs from the regular producer/consumer problem because of the response back.
This is what I'm thinking:
main
{
construct workers
push to shared input buffers
notify workers
wait
print results from shared output buffer
}
worker
{
wait
read from shared input buffer
do work
notify main
}
Am I on the right track? Is there a chance that the worker could respond before main starts waiting?
(I'm using C++ if that is relevant)