QTrk
Public Member Functions | Public Attributes | List of all members
Threads::Mutex Struct Reference

#include <threads.h>

Public Member Functions

 Mutex (const char *name=0)
 
 ~Mutex ()
 
void lock ()
 
void unlock ()
 
void msg (const char *m)
 

Public Attributes

HANDLE h
 
std::string name
 
bool trace
 
int lockCount
 

Detailed Description

Definition at line 61 of file threads.h.

Constructor & Destructor Documentation

§ Mutex()

Threads::Mutex::Mutex ( const char *  name = 0)
inline

Definition at line 67 of file threads.h.

67  : name(name?name:"") {
68  msg("create");
69  h=CreateMutex(0,FALSE,0);
70  trace=false;
71  lockCount=0;
72  }
bool trace
Definition: threads.h:64
std::string name
Definition: threads.h:63
HANDLE h
Definition: threads.h:62
void msg(const char *m)
Definition: threads.h:84
int lockCount
Definition: threads.h:65

§ ~Mutex()

Threads::Mutex::~Mutex ( )
inline

Definition at line 73 of file threads.h.

73 { msg("end"); CloseHandle(h); }
HANDLE h
Definition: threads.h:62
void msg(const char *m)
Definition: threads.h:84

Member Function Documentation

§ lock()

void Threads::Mutex::lock ( )
inline

Definition at line 74 of file threads.h.

74  {
75  msg("lock");
76  WaitForSingleObject(h, INFINITE);
77  lockCount++;
78  }
HANDLE h
Definition: threads.h:62
void msg(const char *m)
Definition: threads.h:84
int lockCount
Definition: threads.h:65

§ msg()

void Threads::Mutex::msg ( const char *  m)
inline

Definition at line 84 of file threads.h.

84  {
85  if(name.length()>0 && trace) {
86  char buf[32];
87  SNPRINTF(buf, sizeof(buf), "mutex %s: %s\n", name.c_str(), m);
88  OutputDebugString(buf);
89  }
90  }
#define SNPRINTF
Definition: std_incl.h:149
bool trace
Definition: threads.h:64
std::string name
Definition: threads.h:63

§ unlock()

void Threads::Mutex::unlock ( )
inline

Definition at line 79 of file threads.h.

79  {
80  msg("unlock");
81  lockCount--;
82  ReleaseMutex(h);
83  }
HANDLE h
Definition: threads.h:62
void msg(const char *m)
Definition: threads.h:84
int lockCount
Definition: threads.h:65

Member Data Documentation

§ h

HANDLE Threads::Mutex::h

Definition at line 62 of file threads.h.

§ lockCount

int Threads::Mutex::lockCount

Definition at line 65 of file threads.h.

§ name

std::string Threads::Mutex::name

Definition at line 63 of file threads.h.

§ trace

bool Threads::Mutex::trace

Definition at line 64 of file threads.h.


The documentation for this struct was generated from the following file: