I need to rewrite some code that uses the windows WaitforSingleObject function.
myEvent = CreateEvent( NULL, FALSE, FALSE, szName );
WaitForSingleObject( myEvent, nMilliseconds );
I need to wait for an event or for a timeout to happen. Is there an equivalent to this in straight C++??
I am using STL C++11 and not any other libraries such as boost.
You can't use C++11 thread routines with win32 threads (unless you heavily mess up with mingw thread implementations, something I would not recommend) and there's no standard C++ equivalent to an OS-specific API call.
You can, however use C++11 threads and use condition variables (cfr. waiting) to accomplish the same thing that WaitForSingleObject does, i.e.
Edit: specifically you would need wait_until
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With