I understand I’ve asked this question before: What is the C++ equivalent for AutoResetEvent under Linux?
However, I’m learning that in C++0x, the threading library are made much simpler, so I want to pose this question out again, is there an easy way to implement AutoResetEvent in C++0x?
Here is a translation of the accepted answer to your first question to use C++11 tools:
Output:
Update
In the comments below tobsen notes that
AutoResetEventhas the semantics ofsignal_.notify_all()instead ofsignal_.notify_one(). I haven’t changed the code because the accepted answer to the first question usedpthread_cond_signalas opposed topthread_cond_broadcastand I am leading with the statement that this is a faithful translation of that answer.