1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- #include "rsMutex.h"
- namespace android {
- namespace renderscript {
- Mutex::Mutex() {
- }
- Mutex::~Mutex() {
- pthread_mutex_destroy(&mMutex);
- }
- bool Mutex::init() {
- int status = pthread_mutex_init(&mMutex, nullptr);
- if (status) {
- ALOGE("Mutex::Mutex init failure");
- return false;
- }
- return true;
- }
- bool Mutex::lock() {
- int status;
- status = pthread_mutex_lock(&mMutex);
- if (status) {
- ALOGE("Mutex: error %i locking.", status);
- return false;
- }
- return true;
- }
- bool Mutex::unlock() {
- int status;
- status = pthread_mutex_unlock(&mMutex);
- if (status) {
- ALOGE("Mutex error %i unlocking.", status);
- return false;
- }
- return true;
- }
- }
- }
|