GClasses
GClasses::GSpinLock Class Reference

Detailed Description

On Windows, this implements a spin-lock. On Linux, this wraps pthread_mutex.

#include <GThread.h>

Public Member Functions

 GSpinLock ()
 
virtual ~GSpinLock ()
 
bool isLocked ()
 
void lock (const char *szWhoHoldsTheLock)
 
void unlock ()
 

Static Public Member Functions

static void test ()
 Performs unit tests for this class. Throws an exception if there is a failure. More...
 

Protected Attributes

volatile long m_dwLocked
 
pthread_mutex_t m_mutex
 maintaned on all platform as posix mutexes don't have a way to get current state. when not Win32 be aware that this value is shadowing the real mutex, and cannot be depended on especially in a MP enviroment. More...
 

Constructor & Destructor Documentation

GClasses::GSpinLock::GSpinLock ( )
virtual GClasses::GSpinLock::~GSpinLock ( )
virtual

Member Function Documentation

bool GClasses::GSpinLock::isLocked ( )
inline
void GClasses::GSpinLock::lock ( const char *  szWhoHoldsTheLock)
static void GClasses::GSpinLock::test ( )
static

Performs unit tests for this class. Throws an exception if there is a failure.

void GClasses::GSpinLock::unlock ( )

Member Data Documentation

volatile long GClasses::GSpinLock::m_dwLocked
protected
pthread_mutex_t GClasses::GSpinLock::m_mutex
protected

maintaned on all platform as posix mutexes don't have a way to get current state. when not Win32 be aware that this value is shadowing the real mutex, and cannot be depended on especially in a MP enviroment.