View Single Post
Old Apr 10th, 2006, 12:01 AM   #4
The Dark
Expert Programmer
 
Join Date: Jun 2005
Posts: 884
Rep Power: 4 The Dark is on a distinguished road
Probably the simplest mutex to use in Windows is the critical section functions.

InitializeCriticalSection;
DeleteCriticalSection;
EnterCriticalSection;
LeaveCriticalSection;

each of these take a pointer to a CRITICAL_SECTION value. Call Initialize once to create the critical section, then call the Enter and Leave functions to lock and unlock it, then call Delete when you are done.

I'd recommend wrapping the calls in a class, and possibly even having a smart "locking" class that you create when you want to lock the mutex (pass the mutex in) that automatically unlocks when the object is destroyed.

There are probably lots of options in other third party libraries as well.
The Dark is offline   Reply With Quote