Usage of c++ monitor wrapper Topic is solved
Posted: Wed Jul 03, 2019 5:20 pm
I am confused on how to use the monitor class.
From what I have learnt, a monitor is used to guard data and allow threads to wait for their change, where modification and observation to the data is only done when the mutex is held.
However the monitor class inherited mutex with "protected" making it impossible to be locked, and it only provides wait, signal and broadcast functions.
I wonder whether this is a intended behavior.
In addition, I would like to be advised on how to "wait on multiple condition variables", where anyone of the condition variable can wake up the suspended thread notifying the signaled conditional variable.
Thank you very much.
From what I have learnt, a monitor is used to guard data and allow threads to wait for their change, where modification and observation to the data is only done when the mutex is held.
However the monitor class inherited mutex with "protected" making it impossible to be locked, and it only provides wait, signal and broadcast functions.
I wonder whether this is a intended behavior.
In addition, I would like to be advised on how to "wait on multiple condition variables", where anyone of the condition variable can wake up the suspended thread notifying the signaled conditional variable.
Thank you very much.