Я думаю, вам нужно использовать boost::mutex
, boost::unique_lock
, boost::condition_variable
и, возможно, bool
для имитации событий.
На самом деле вам может понадобиться что-то вроде WaitForSingleObject
, чтобы дождаться события. Может быть так:
void wait_for_user_input()
{
boost::unique_lock<boost::mutex> lock(mut);
while(!data_ready)
{
cond.wait(lock);
}
process_user_input(); // it might be not necessary to hold mutex locked here!!!
// if so just add curly braces like this:
// void wait_for_user_input()
// {
// {
// boost::unique_lock<boost::mutex> lock(mut);
// while(!data_ready) { cond.wait(lock); }
// }
// process_user_input();
// }
}