Commit 7859058e by Zhixun Tan Committed by Tianqi Chen

Name all the lock guards. (#938)

parent ca8e31ff
......@@ -24,7 +24,7 @@ struct LLVMEnv {
void InitializeLLVM() {
LLVMEnv* e = LLVMEnv::Global();
if (!e->all_initialized) {
std::lock_guard<std::mutex>(e->mu);
std::lock_guard<std::mutex> lock(e->mu);
if (!e->all_initialized) {
e->all_initialized = true;
llvm::InitializeAllTargetInfos();
......
......@@ -96,7 +96,7 @@ MetalWorkspace::~MetalWorkspace() {
void MetalWorkspace::Init() {
if (initialized_) return;
std::lock_guard<std::mutex>(this->mutex);
std::lock_guard<std::mutex> lock(this->mutex);
if (initialized_) return;
initialized_ = true;
if (devices.size() != 0) return;
......
......@@ -180,7 +180,7 @@ bool MatchPlatformInfo(
void OpenCLWorkspace::Init() {
if (initialized_) return;
std::lock_guard<std::mutex>(this->mu);
std::lock_guard<std::mutex> lock(this->mu);
if (initialized_) return;
initialized_ = true;
if (context != nullptr) return;
......
......@@ -46,7 +46,7 @@ Registry& Registry::set_body(PackedFunc f) { // NOLINT(*)
Registry& Registry::Register(const std::string& name, bool override) { // NOLINT(*)
Manager* m = Manager::Global();
std::lock_guard<std::mutex>(m->mutex);
std::lock_guard<std::mutex> lock(m->mutex);
auto it = m->fmap.find(name);
if (it == m->fmap.end()) {
Registry* r = new Registry();
......@@ -62,7 +62,7 @@ Registry& Registry::Register(const std::string& name, bool override) { // NOLIN
bool Registry::Remove(const std::string& name) {
Manager* m = Manager::Global();
std::lock_guard<std::mutex>(m->mutex);
std::lock_guard<std::mutex> lock(m->mutex);
auto it = m->fmap.find(name);
if (it == m->fmap.end()) return false;
m->fmap.erase(it);
......@@ -71,7 +71,7 @@ bool Registry::Remove(const std::string& name) {
const PackedFunc* Registry::Get(const std::string& name) {
Manager* m = Manager::Global();
std::lock_guard<std::mutex>(m->mutex);
std::lock_guard<std::mutex> lock(m->mutex);
auto it = m->fmap.find(name);
if (it == m->fmap.end()) return nullptr;
return &(it->second->func_);
......@@ -79,7 +79,7 @@ const PackedFunc* Registry::Get(const std::string& name) {
std::vector<std::string> Registry::ListNames() {
Manager* m = Manager::Global();
std::lock_guard<std::mutex>(m->mutex);
std::lock_guard<std::mutex> lock(m->mutex);
std::vector<std::string> keys;
keys.reserve(m->fmap.size());
for (const auto &kv : m->fmap) {
......@@ -101,7 +101,7 @@ ExtTypeVTable* ExtTypeVTable::RegisterInternal(
int type_code, const ExtTypeVTable& vt) {
CHECK(type_code > kExtBegin && type_code < kExtEnd);
Registry::Manager* m = Registry::Manager::Global();
std::lock_guard<std::mutex>(m->mutex);
std::lock_guard<std::mutex> lock(m->mutex);
ExtTypeVTable* pvt = &(m->ext_vtable[type_code]);
pvt[0] = vt;
return pvt;
......
......@@ -650,7 +650,7 @@ std::vector<VulkanContext> GetContext(VkInstance instance) {
void VulkanWorkspace::Init() {
if (initialized_) return;
std::lock_guard<std::mutex>(this->mu);
std::lock_guard<std::mutex> lock(this->mu);
if (initialized_) return;
initialized_ = true;
instance_ = CreateInstance();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment