From 10223e886c130c23aba65168e344c2f6eb28657d Mon Sep 17 00:00:00 2001 From: David Neto Date: Thu, 21 Apr 2016 15:46:11 -0400 Subject: [PATCH] Remove use of std::mutex in gtest code. Gtest runs in single-threaded mode. So the GlslangInitializer object in the test code doesn't have to do its own synchronization. --- gtests/Initializer.h | 38 +++----------------------------------- 1 file changed, 3 insertions(+), 35 deletions(-) diff --git a/gtests/Initializer.h b/gtests/Initializer.h index e8fa30d..3cd91a0 100644 --- a/gtests/Initializer.h +++ b/gtests/Initializer.h @@ -35,8 +35,6 @@ #ifndef GLSLANG_GTESTS_INITIALIZER_H #define GLSLANG_GTESTS_INITIALIZER_H -#include - #include "glslang/Public/ShaderLang.h" namespace glslangtest { @@ -63,55 +61,25 @@ public: // A token indicates that the glslang is reinitialized (if necessary) to the // required semantics. And that won't change until the token is destroyed. class InitializationToken { - public: - InitializationToken() : initializer(nullptr) {} - ~InitializationToken() - { - if (initializer) { - initializer->release(); - } - } - - InitializationToken(InitializationToken&& other) - : initializer(other.initializer) - { - other.initializer = nullptr; - } - - InitializationToken(const InitializationToken&) = delete; - - private: - InitializationToken(GlslangInitializer* initializer) - : initializer(initializer) {} - - friend class GlslangInitializer; - GlslangInitializer* initializer; }; - // Obtains exclusive access to the glslang state. The state remains - // exclusive until the Initialization Token has been destroyed. // Re-initializes glsl state iff the previous messages and the current - // messages are incompatible. + // messages are incompatible. We assume external synchronization, i.e. + // there is at most one acquired token at any one time. InitializationToken acquire(EShMessages new_messages) { - stateLock.lock(); - if ((lastMessages ^ new_messages) & (EShMsgVulkanRules | EShMsgSpvRules)) { glslang::FinalizeProcess(); glslang::InitializeProcess(); } lastMessages = new_messages; - return InitializationToken(this); + return InitializationToken(); } private: - void release() { stateLock.unlock(); } - - friend class InitializationToken; EShMessages lastMessages; - std::mutex stateLock; }; } // namespace glslangtest -- 2.7.4