source: cheroxy/branches/b0_1_threading/src/CRXMutex.cpp@ 7

Last change on this file since 7 was 7, checked in by cheese, 12 years ago

#1 스레딩 모듈 추가 브랜치

File size: 667 bytes
Line 
1
2#include "CRXMutex.h"
3
4CRXMutex::CRXMutex (void)
5{
6#ifdef _WIN32
7 mMutex = NULL;
8#endif
9}
10
11CRXMutex::~CRXMutex (void)
12{
13 this->Unlock ();
14#ifdef _WIN32
15#else
16#endif
17}
18
19int CRXMutex::Create ()
20{
21#ifdef _WIN32
22 if ((mMutex = ::CreateMutexA(NULL, FALSE, NULL)) == NULL)
23 return -1;
24#else
25 pthread_mutex_init (&mMutex, NULL);
26#endif
27
28 return 0;
29}
30
31void CRXMutex::Lock (void)
32{
33#ifdef _WIN32
34 ::WaitForSingleObject (mMutex, INFINITE);
35#else
36 pthread_mutex_lock (&mMutex);
37#endif
38}
39
40void CRXMutex::Unlock (void)
41{
42#ifdef _WIN32
43 if (mMutex != NULL)
44 ::ReleaseMutex(mMutex);
45#else
46 pthread_mutex_unlock (&mMutex);
47#endif
48}
Note: See TracBrowser for help on using the repository browser.