123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- #include "mutex.h"
- namespace cmb {
- #if defined(_MSC_VER)
- mutex::mutex()
- {
- ::InitializeCriticalSection(&csection_);
- }
- mutex::~mutex()
- {
- ::DeleteCriticalSection(&csection_);
- }
- void mutex::lock()
- {
- ::EnterCriticalSection(&csection_);
- }
- void mutex::unlock()
- {
- ::LeaveCriticalSection(&csection_);
- }
- #elif defined(__GNUC__)
- mutex::mutex()
- {
- pthread_mutex_init(&mutx_, NULL);
- }
- mutex::~mutex()
- {
- pthread_mutex_destroy(&mutx_);
- }
- void mutex::lock()
- {
- pthread_mutex_lock(&mutx_);
- }
- void mutex::unlock()
- {
- pthread_mutex_unlock(&mutx_);
- }
- #endif
- }
|