This source file includes following definitions.
- Acquire
- Release
- Acquire
- Release
#include "ppapi/utility/threading/lock.h"
namespace pp {
#ifdef WIN32
Lock::Lock() {
::InitializeCriticalSectionAndSpinCount(&os_lock_, 2000);
}
Lock::~Lock() {
::DeleteCriticalSection(&os_lock_);
}
void Lock::Acquire() {
::EnterCriticalSection(&os_lock_);
}
void Lock::Release() {
::LeaveCriticalSection(&os_lock_);
}
#else
Lock::Lock() {
pthread_mutex_init(&os_lock_, NULL);
}
Lock::~Lock() {
pthread_mutex_destroy(&os_lock_);
}
void Lock::Acquire() {
pthread_mutex_lock(&os_lock_);
}
void Lock::Release() {
pthread_mutex_unlock(&os_lock_);
}
#endif
}