I think it is wrong. You replaced the
while
with an
if
, but you need the loop (for the spurious wake-ups). And you are setting
work_to_do=true
in
wait()
, while it should be
work_to_do=false
. The
else return;
is pretty useless. You do not need the
scoped_lock()
in the constructor because constructors are not run concurrently. You are missing a few variable names:
boost::mutex::scoped_lock(mutex);
does nothing useful! All that said, you can write a wrapper that does what you want, but it is not a good format for a SO question, more for CodeReview... —
rodrigo just now