2019-04-17 10:49:11 +08:00
|
|
|
//
|
|
|
|
// GLLock.cpp
|
|
|
|
// MNN
|
|
|
|
//
|
|
|
|
// Created by MNN on 2019/01/31.
|
|
|
|
// Copyright © 2018, Alibaba Group Holding Limited
|
|
|
|
//
|
|
|
|
|
2019-12-27 22:16:57 +08:00
|
|
|
#include "backend/opengl/GLLock.hpp"
|
2019-04-17 10:49:11 +08:00
|
|
|
#include <assert.h>
|
|
|
|
#include <pthread.h>
|
|
|
|
namespace MNN {
|
2019-05-24 11:26:54 +08:00
|
|
|
namespace OpenGL {
|
2019-04-17 10:49:11 +08:00
|
|
|
GLLock::GLLock() {
|
|
|
|
pthread_mutex_t* m = new pthread_mutex_t;
|
|
|
|
pthread_mutex_init(m, NULL);
|
|
|
|
mData = (void*)m;
|
|
|
|
}
|
|
|
|
|
|
|
|
GLLock::~GLLock() {
|
|
|
|
assert(NULL != mData);
|
|
|
|
pthread_mutex_t* m = (pthread_mutex_t*)mData;
|
|
|
|
pthread_mutex_destroy(m);
|
|
|
|
delete m;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GLLock::lock() {
|
|
|
|
assert(NULL != mData);
|
|
|
|
pthread_mutex_lock((pthread_mutex_t*)mData);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GLLock::unlock() {
|
|
|
|
assert(NULL != mData);
|
|
|
|
pthread_mutex_unlock((pthread_mutex_t*)mData);
|
|
|
|
}
|
2019-05-24 11:26:54 +08:00
|
|
|
} // namespace OpenGL
|
2019-04-17 10:49:11 +08:00
|
|
|
} // namespace MNN
|