In windows, the code that creates a mutual exclusive section uses the
'Event' mechanism.
HANDLE sync = CreateEvent (&sa, FALSE, TRUE, TEXT
("Global\\zmq-signaler-port-sync"));
if (sync == NULL && GetLastError () == ERROR_ACCESS_DENIED)
sync = OpenEvent (SYNCHRONIZE | EVENT_MODIFY_STATE, FALSE, TEXT
("Global\\zmq-signaler-port-sync"));
win_assert (sync != NULL);
// Enter the critical section.
DWORD dwrc = WaitForSingleObject (sync, INFINITE);
zmq_assert (dwrc == WAIT_OBJECT_0);
// Some code here...
brc = SetEvent (sync);
brc = CloseHandle (sync);
win_assert and zmq_asserts abort the program if the conditions passed to
them aren't met. If the program is aborted before calling 'SetEvent' on
sync, the event is unsetted forever and all zeromq applications that
call this code will block on 'WaitForSingleObject'. A preferred way to
handle this is using 'Mutex' since if this scenario happens,
WaitForSingleObject will not freeze forever but will return WAIT_ABANDONED.
_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev