I've been searching the web for quite a while now and I've come across a few answers here on SO, but they didn't really answer my questions.
Before I head on, these are some of the questions I checked out: Equivalence of WaitForSingleObject() & ResetEvent() in Linux, Linux/POSIX equivalent for Win32's CreateEvent, SetEvent, WaitForSingleObject, Linux WaitForSingleObject?
I'm currently porting proprietary code that was developed a few years ago to update our ECUs on our machines. The code was originally developed for WinCE (which is what runs on the terminals in the cabin and on the ECU itself).
Most of the code is ported, it compiles and links and I'm still implementing a new updater around the ported code, however there is one piece of the puzzle that is missing. I have a structure that contains HANDLEs. I've re-used these intptrs so I can use them to manage file descriptors, however the code requires WaitForSingleObject to wait on other HANDLEs.
if (WaitForSingleObject(updateStruct->abortEvent, 0) == WAIT_OBJECT_0)
{
updateStruct->errorNumber = 0x0014L;
return FALSE;
}
I've read a lot about using pthreads, I even found a library called pevents that supposedly translates WinAPI calls to POSIX calls, however most of the solutions I've found either require C++11 (which I can't use for reasons I'm not entirely sure of myself) or they're simply not implementable because I'm required to leave the code as intact as possible so it can be compiled/used on the original platform - so I can't simply switch from using HANDLEs.
Is there a relatively straightforward way to implement this kind of function with C++98/03? I could always pfusch it and just create a loop that loops for the amount of the timeout and run in to the timeout, but then the application won't work, so that's not really an option ;)