System: Replace concurrent types with std versions where possible

Replace sw::MutexLock with std::mutex.
Replace use of sw::Thread with std::thread.

helgrind seems to take objection to the init Event.

AtomicInt remains as a wrapper around std::atomic<int> as it provides an 'operator=' and
'std::atomic& operator=( const std::atomic& )' is deleted.

This change is to reduce the amount of code I have to verify while looking for synchronization issues.

Bug: b/133127573
Change-Id: I8cbe38c918298ffafaf59fe25b0ff258670f9a99
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/31812
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Ben Clayton <bclayton@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1e43eca..cd90023 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1604,7 +1604,6 @@
     ${SOURCE_DIR}/System/Socket.cpp
     ${SOURCE_DIR}/System/Socket.hpp
     ${SOURCE_DIR}/System/Synchronization.hpp
-    ${SOURCE_DIR}/System/Thread.cpp
     ${SOURCE_DIR}/System/Thread.hpp
     ${SOURCE_DIR}/System/Timer.cpp
     ${SOURCE_DIR}/System/Timer.hpp
diff --git a/build/Visual Studio 15 2017 Win64/libvk_swiftshader.vcxproj b/build/Visual Studio 15 2017 Win64/libvk_swiftshader.vcxproj
index 189af17..78c03e3 100644
--- a/build/Visual Studio 15 2017 Win64/libvk_swiftshader.vcxproj
+++ b/build/Visual Studio 15 2017 Win64/libvk_swiftshader.vcxproj
@@ -264,7 +264,6 @@
     <ClCompile Include="$(SolutionDir)src\System\Socket.cpp" />

     <ClInclude Include="$(SolutionDir)src\System\Socket.hpp" />

     <ClInclude Include="$(SolutionDir)src\System\Synchronization.hpp" />

-    <ClCompile Include="$(SolutionDir)src\System\Thread.cpp" />

     <ClInclude Include="$(SolutionDir)src\System\Thread.hpp" />

     <ClCompile Include="$(SolutionDir)src\System\Timer.cpp" />

     <ClInclude Include="$(SolutionDir)src\System\Timer.hpp" />

diff --git a/build/Visual Studio 15 2017 Win64/libvk_swiftshader.vcxproj.filters b/build/Visual Studio 15 2017 Win64/libvk_swiftshader.vcxproj.filters
index 0550e3d..64fbb92 100644
--- a/build/Visual Studio 15 2017 Win64/libvk_swiftshader.vcxproj.filters
+++ b/build/Visual Studio 15 2017 Win64/libvk_swiftshader.vcxproj.filters
@@ -109,9 +109,6 @@
     <ClCompile Include="$(SolutionDir)src\System\Socket.cpp">

       <Filter>src\System</Filter>

     </ClCompile>

-    <ClCompile Include="$(SolutionDir)src\System\Thread.cpp">

-      <Filter>src\System</Filter>

-    </ClCompile>

     <ClCompile Include="$(SolutionDir)src\System\Timer.cpp">

       <Filter>src\System</Filter>

     </ClCompile>

diff --git a/src/Android.bp b/src/Android.bp
index de2a228..ced6649 100644
--- a/src/Android.bp
+++ b/src/Android.bp
@@ -654,7 +654,6 @@
         "System/Memory.cpp",
         "System/Resource.cpp",
         "System/Socket.cpp",
-        "System/Thread.cpp",
         "System/Timer.cpp",
         "System/DebugAndroid.cpp",
         "System/GrallocAndroid.cpp",
diff --git a/src/Device/Blitter.hpp b/src/Device/Blitter.hpp
index b7c4af5..513bf86 100644
--- a/src/Device/Blitter.hpp
+++ b/src/Device/Blitter.hpp
@@ -17,9 +17,9 @@
 
 #include "RoutineCache.hpp"
 #include "Reactor/Reactor.hpp"
-#include "System/MutexLock.hpp"
 #include "Vulkan/VkFormat.h"
 
+#include <mutex>
 #include <string.h>
 
 namespace vk
@@ -144,7 +144,7 @@
 
 		RoutineCache<State> *blitCache;
 		RoutineCache<State> *cornerUpdateCache;
-		MutexLock criticalSection;
+		std::mutex criticalSection;
 	};
 }
 
diff --git a/src/Device/Renderer.cpp b/src/Device/Renderer.cpp
index cce1724..85eb7f4 100644
--- a/src/Device/Renderer.cpp
+++ b/src/Device/Renderer.cpp
@@ -20,7 +20,6 @@
 #include "Device/SwiftConfig.hpp"
 #include "Reactor/Reactor.hpp"
 #include "Pipeline/Constants.hpp"
-#include "System/MutexLock.hpp"
 #include "System/CPUID.hpp"
 #include "System/Memory.hpp"
 #include "System/Resource.hpp"
@@ -1344,7 +1343,7 @@
 			parameters.renderer = this;
 
 			exitThreads = false;
-			worker[i] = new Thread(threadFunction, &parameters);
+			worker[i] = new std::thread(threadFunction, &parameters);
 
 			suspend[i]->wait();
 			suspend[i]->signal();
@@ -1355,7 +1354,7 @@
 	{
 		while(threadsAwake != 0)
 		{
-			Thread::sleep(1);
+			std::this_thread::yield();
 		}
 
 		for(int thread = 0; thread < threadCount; thread++)
diff --git a/src/Device/Renderer.hpp b/src/Device/Renderer.hpp
index 9768b08..0d01f45 100644
--- a/src/Device/Renderer.hpp
+++ b/src/Device/Renderer.hpp
@@ -20,12 +20,14 @@
 #include "SetupProcessor.hpp"
 #include "Plane.hpp"
 #include "Blitter.hpp"
-#include "System/MutexLock.hpp"
-#include "System/Thread.hpp"
 #include "Device/Config.hpp"
+#include "System/Synchronization.hpp"
+#include "System/Thread.hpp"
 #include "Vulkan/VkDescriptorSet.hpp"
 
 #include <list>
+#include <mutex>
+#include <thread>
 
 namespace vk
 {
@@ -255,7 +257,7 @@
 
 		AtomicInt exitThreads;
 		AtomicInt threadsAwake;
-		Thread *worker[16];
+		std::thread *worker[16];
 		Event *resume[16];         // Events for resuming threads
 		Event *suspend[16];        // Events for suspending threads
 		Event *resumeApp;          // Event for resuming the application thread
@@ -285,7 +287,7 @@
 		static AtomicInt unitCount;
 		static AtomicInt clusterCount;
 
-		MutexLock schedulerMutex;
+		std::mutex schedulerMutex;
 
 		#if PERF_HUD
 			int64_t vertexTime[16];
diff --git a/src/Device/SwiftConfig.cpp b/src/Device/SwiftConfig.cpp
index a7303fc..5e1c2f9 100644
--- a/src/Device/SwiftConfig.cpp
+++ b/src/Device/SwiftConfig.cpp
@@ -76,7 +76,7 @@
 		listenSocket->listen();
 
 		terminate = false;
-		serverThread = new Thread(serverRoutine, this);
+		serverThread = new std::thread(serverRoutine, this);
 	}
 
 	void SwiftConfig::destroyServer()
diff --git a/src/Device/SwiftConfig.hpp b/src/Device/SwiftConfig.hpp
index 5b3aefa..b470db5 100644
--- a/src/Device/SwiftConfig.hpp
+++ b/src/Device/SwiftConfig.hpp
@@ -17,11 +17,11 @@
 
 #include "Reactor/Nucleus.hpp"
 
-#include "System/Thread.hpp"
-#include "System/MutexLock.hpp"
 #include "System/Socket.hpp"
 
+#include <mutex>
 #include <string>
+#include <thread>
 
 #ifdef Status
 #undef Status // b/127920555
@@ -101,9 +101,9 @@
 
 		Configuration config;
 
-		Thread *serverThread;
+		std::thread *serverThread;
 		volatile bool terminate;
-		MutexLock criticalSection;   // Protects reading and writing the configuration settings
+		std::mutex criticalSection;   // Protects reading and writing the configuration settings
 
 		bool newConfig;
 
diff --git a/src/System/MutexLock.hpp b/src/System/MutexLock.hpp
deleted file mode 100644
index 65e9fa4..0000000
--- a/src/System/MutexLock.hpp
+++ /dev/null
@@ -1,199 +0,0 @@
-// Copyright 2016 The SwiftShader Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//    http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef sw_MutexLock_hpp
-#define sw_MutexLock_hpp
-
-#include "Thread.hpp"
-
-#if defined(__linux__)
-// Use a pthread mutex on Linux. Since many processes may use SwiftShader
-// at the same time it's best to just have the scheduler overhead.
-#include <pthread.h>
-
-namespace sw
-{
-	class MutexLock
-	{
-	public:
-		MutexLock()
-		{
-			pthread_mutex_init(&mutex, NULL);
-		}
-
-		~MutexLock()
-		{
-			pthread_mutex_destroy(&mutex);
-		}
-
-		bool attemptLock()
-		{
-			return pthread_mutex_trylock(&mutex) == 0;
-		}
-
-		void lock()
-		{
-			pthread_mutex_lock(&mutex);
-		}
-
-		void unlock()
-		{
-			pthread_mutex_unlock(&mutex);
-		}
-
-	private:
-		pthread_mutex_t mutex;
-	};
-}
-
-#else   // !__linux__
-
-#include <atomic>
-
-namespace sw
-{
-	class BackoffLock
-	{
-	public:
-		BackoffLock()
-		{
-			mutex = 0;
-		}
-
-		bool attemptLock()
-		{
-			if(!isLocked())
-			{
-				if(mutex.exchange(true) == false)
-				{
-					return true;
-				}
-			}
-
-			return false;
-		}
-
-		void lock()
-		{
-			int backoff = 1;
-
-			while(!attemptLock())
-			{
-				if(backoff <= 64)
-				{
-					for(int i = 0; i < backoff; i++)
-					{
-						nop();
-						nop();
-						nop();
-						nop();
-						nop();
-
-						nop();
-						nop();
-						nop();
-						nop();
-						nop();
-
-						nop();
-						nop();
-						nop();
-						nop();
-						nop();
-
-						nop();
-						nop();
-						nop();
-						nop();
-						nop();
-
-						nop();
-						nop();
-						nop();
-						nop();
-						nop();
-
-						nop();
-						nop();
-						nop();
-						nop();
-						nop();
-
-						nop();
-						nop();
-						nop();
-						nop();
-						nop();
-					}
-
-					backoff *= 2;
-				}
-				else
-				{
-					Thread::yield();
-
-					backoff = 1;
-				}
-			};
-		}
-
-		void unlock()
-		{
-			mutex.store(false, std::memory_order_release);
-		}
-
-		bool isLocked()
-		{
-			return mutex.load(std::memory_order_acquire);
-		}
-
-	private:
-		struct
-		{
-			// Ensure that the mutex variable is on its own 64-byte cache line to avoid false sharing
-			// Padding must be public to avoid compiler warnings
-			volatile int padding1[16];
-			std::atomic<bool> mutex;
-			volatile int padding2[15];
-		};
-	};
-
-	using MutexLock = BackoffLock;
-}
-
-#endif   // !__ANDROID__
-
-class LockGuard
-{
-public:
-	explicit LockGuard(sw::MutexLock &mutex) : mutex(&mutex)
-	{
-		mutex.lock();
-	}
-
-	explicit LockGuard(sw::MutexLock *mutex) : mutex(mutex)
-	{
-		if (mutex) mutex->lock();
-	}
-
-	~LockGuard()
-	{
-		if (mutex) mutex->unlock();
-	}
-
-protected:
-	sw::MutexLock *mutex;
-};
-
-#endif   // sw_MutexLock_hpp
diff --git a/src/System/Resource.hpp b/src/System/Resource.hpp
index 0acfa48..7caec8a 100644
--- a/src/System/Resource.hpp
+++ b/src/System/Resource.hpp
@@ -15,7 +15,9 @@
 #ifndef sw_Resource_hpp
 #define sw_Resource_hpp
 
-#include "MutexLock.hpp"
+#include "Synchronization.hpp"
+
+#include <mutex>
 
 namespace sw
 {
@@ -45,7 +47,7 @@
 	private:
 		~Resource();   // Always call destruct() instead
 
-		MutexLock criticalSection;
+		std::mutex criticalSection;
 		Event unblock;
 		volatile int blocked;
 
diff --git a/src/System/Thread.cpp b/src/System/Thread.cpp
deleted file mode 100644
index b50efe4..0000000
--- a/src/System/Thread.cpp
+++ /dev/null
@@ -1,70 +0,0 @@
-// Copyright 2016 The SwiftShader Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//    http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#include "Thread.hpp"
-
-namespace sw
-{
-	Thread::Thread(void (*threadFunction)(void *parameters), void *parameters)
-	{
-		Event init;
-		Entry entry = {threadFunction, parameters, &init};
-
-		#if defined(_WIN32)
-			handle = CreateThread(NULL, 1024 * 1024, startFunction, &entry, 0, NULL);
-		#else
-			pthread_create(&handle, NULL, startFunction, &entry);
-		#endif
-
-		init.wait();
-	}
-
-	Thread::~Thread()
-	{
-		join();   // Make threads exit before deleting them to not block here
-	}
-
-	void Thread::join()
-	{
-		if(!hasJoined)
-		{
-			#if defined(_WIN32)
-				WaitForSingleObject(handle, INFINITE);
-				CloseHandle(handle);
-			#else
-				pthread_join(handle, NULL);
-			#endif
-
-			hasJoined = true;
-		}
-	}
-
-	#if defined(_WIN32)
-		unsigned long __stdcall Thread::startFunction(void *parameters)
-		{
-			Entry entry = *(Entry*)parameters;
-			entry.init->signal();
-			entry.threadFunction(entry.threadParameters);
-			return 0;
-		}
-	#else
-		void *Thread::startFunction(void *parameters)
-		{
-			Entry entry = *(Entry*)parameters;
-			entry.init->signal();
-			entry.threadFunction(entry.threadParameters);
-			return nullptr;
-		}
-	#endif
-}
diff --git a/src/System/Thread.hpp b/src/System/Thread.hpp
index bd737ba..3b6770d 100644
--- a/src/System/Thread.hpp
+++ b/src/System/Thread.hpp
@@ -15,278 +15,28 @@
 #ifndef sw_Thread_hpp
 #define sw_Thread_hpp
 
-#include "Synchronization.hpp"
-
-#if defined(_WIN32)
-	#ifndef WIN32_LEAN_AND_MEAN
-		#define WIN32_LEAN_AND_MEAN
-	#endif
-	#include <windows.h>
-	#include <intrin.h>
-#else
-	#include <pthread.h>
-	#include <sched.h>
-	#include <unistd.h>
-	#define TLS_OUT_OF_INDEXES (pthread_key_t)(~0)
-#endif
-
-#include <stdlib.h>
-
-#if defined(__clang__)
-#if __has_include(<atomic>) // clang has an explicit check for the availability of atomic
-#define USE_STD_ATOMIC 1
-#endif
-// atomic is available in C++11 or newer, and in Visual Studio 2012 or newer
-#elif (defined(_MSC_VER) && (_MSC_VER >= 1700)) || (__cplusplus >= 201103L)
-#define USE_STD_ATOMIC 1
-#endif
-
-#if USE_STD_ATOMIC
 #include <atomic>
-#endif
 
 namespace sw
 {
-	class Thread
+	class AtomicInt
 	{
 	public:
-		Thread(void (*threadFunction)(void *parameters), void *parameters);
+		AtomicInt() : ai() {}
+		AtomicInt(int i) : ai(i) {}
 
-		~Thread();
-
-		void join();
-
-		static void yield();
-		static void sleep(int milliseconds);
-
-		#if defined(_WIN32)
-			typedef DWORD LocalStorageKey;
-		#else
-			typedef pthread_key_t LocalStorageKey;
-		#endif
-
-		static LocalStorageKey allocateLocalStorageKey(void (*destructor)(void *storage) = free);
-		static void freeLocalStorageKey(LocalStorageKey key);
-		static void *allocateLocalStorage(LocalStorageKey key, size_t size);
-		static void *getLocalStorage(LocalStorageKey key);
-		static void freeLocalStorage(LocalStorageKey key);
-
+		inline operator int() const { return ai.load(std::memory_order_acquire); }
+		inline void operator=(const AtomicInt& i) { ai.store(i.ai.load(std::memory_order_acquire), std::memory_order_release); }
+		inline void operator=(int i) { ai.store(i, std::memory_order_release); }
+		inline void operator--() { ai.fetch_sub(1, std::memory_order_acq_rel); }
+		inline void operator++() { ai.fetch_add(1, std::memory_order_acq_rel); }
+		inline int operator--(int) { return ai.fetch_sub(1, std::memory_order_acq_rel) - 1; }
+		inline int operator++(int) { return ai.fetch_add(1, std::memory_order_acq_rel) + 1; }
+		inline void operator-=(int i) { ai.fetch_sub(i, std::memory_order_acq_rel); }
+		inline void operator+=(int i) { ai.fetch_add(i, std::memory_order_acq_rel); }
 	private:
-		struct Entry
-		{
-			void (*const threadFunction)(void *parameters);
-			void *threadParameters;
-			Event *init;
-		};
-
-		#if defined(_WIN32)
-			static unsigned long __stdcall startFunction(void *parameters);
-			HANDLE handle;
-		#else
-			static void *startFunction(void *parameters);
-			pthread_t handle;
-		#endif
-
-		bool hasJoined = false;
+		std::atomic<int> ai;
 	};
-
-	#if PERF_PROFILE
-	int64_t atomicExchange(int64_t volatile *target, int64_t value);
-	int atomicExchange(int volatile *target, int value);
-	#endif
-
-	int atomicIncrement(int volatile *value);
-	int atomicDecrement(int volatile *value);
-	int atomicAdd(int volatile *target, int value);
-	void nop();
-}
-
-namespace sw
-{
-	inline void Thread::yield()
-	{
-		#if defined(_WIN32)
-			Sleep(0);
-		#elif defined(__APPLE__)
-			pthread_yield_np();
-		#else
-			sched_yield();
-		#endif
-	}
-
-	inline void Thread::sleep(int milliseconds)
-	{
-		#if defined(_WIN32)
-			Sleep(milliseconds);
-		#else
-			usleep(1000 * milliseconds);
-		#endif
-	}
-
-	inline Thread::LocalStorageKey Thread::allocateLocalStorageKey(void (*destructor)(void *storage))
-	{
-		#if defined(_WIN32)
-			return TlsAlloc();
-		#else
-			LocalStorageKey key;
-			pthread_key_create(&key, destructor);
-			return key;
-		#endif
-	}
-
-	inline void Thread::freeLocalStorageKey(LocalStorageKey key)
-	{
-		#if defined(_WIN32)
-			TlsFree(key);
-		#else
-			pthread_key_delete(key);   // Using an invalid key is an error but not undefined behavior.
-		#endif
-	}
-
-	inline void *Thread::allocateLocalStorage(LocalStorageKey key, size_t size)
-	{
-		if(key == TLS_OUT_OF_INDEXES)
-		{
-			return nullptr;
-		}
-
-		freeLocalStorage(key);
-
-		void *storage = malloc(size);
-
-		#if defined(_WIN32)
-			TlsSetValue(key, storage);
-		#else
-			pthread_setspecific(key, storage);
-		#endif
-
-		return storage;
-	}
-
-	inline void *Thread::getLocalStorage(LocalStorageKey key)
-	{
-		#if defined(_WIN32)
-			return TlsGetValue(key);
-		#else
-			if(key == TLS_OUT_OF_INDEXES)   // Avoid undefined behavior.
-			{
-				return nullptr;
-			}
-
-			return pthread_getspecific(key);
-		#endif
-	}
-
-	inline void Thread::freeLocalStorage(LocalStorageKey key)
-	{
-		free(getLocalStorage(key));
-
-		#if defined(_WIN32)
-			TlsSetValue(key, nullptr);
-		#else
-			pthread_setspecific(key, nullptr);
-		#endif
-	}
-
-	#if PERF_PROFILE
-	inline int64_t atomicExchange(volatile int64_t *target, int64_t value)
-	{
-		#if defined(_WIN32)
-			return InterlockedExchange64(target, value);
-		#else
-			int ret;
-			__asm__ __volatile__("lock; xchg8 %x0,(%x1)" : "=r" (ret) :"r" (target), "0" (value) : "memory" );
-			return ret;
-		#endif
-	}
-
-	inline int atomicExchange(volatile int *target, int value)
-	{
-		#if defined(_WIN32)
-			return InterlockedExchange((volatile long*)target, (long)value);
-		#else
-			int ret;
-			__asm__ __volatile__("lock; xchgl %x0,(%x1)" : "=r" (ret) :"r" (target), "0" (value) : "memory" );
-			return ret;
-		#endif
-	}
-	#endif
-
-	inline int atomicIncrement(volatile int *value)
-	{
-		#if defined(_WIN32)
-			return InterlockedIncrement((volatile long*)value);
-		#else
-			return __sync_add_and_fetch(value, 1);
-		#endif
-	}
-
-	inline int atomicDecrement(volatile int *value)
-	{
-		#if defined(_WIN32)
-			return InterlockedDecrement((volatile long*)value);
-		#else
-			return __sync_sub_and_fetch(value, 1);
-		#endif
-	}
-
-	inline int atomicAdd(volatile int* target, int value)
-	{
-		#if defined(_WIN32)
-			return InterlockedExchangeAdd((volatile long*)target, value) + value;
-		#else
-			return __sync_add_and_fetch(target, value);
-		#endif
-	}
-
-	inline void nop()
-	{
-		#if defined(_WIN32)
-			__nop();
-		#else
-			__asm__ __volatile__ ("nop");
-		#endif
-	}
-
-	#if USE_STD_ATOMIC
-		class AtomicInt
-		{
-		public:
-			AtomicInt() : ai() {}
-			AtomicInt(int i) : ai(i) {}
-
-			inline operator int() const { return ai.load(std::memory_order_acquire); }
-			inline void operator=(const AtomicInt& i) { ai.store(i.ai.load(std::memory_order_acquire), std::memory_order_release); }
-			inline void operator=(int i) { ai.store(i, std::memory_order_release); }
-			inline void operator--() { ai.fetch_sub(1, std::memory_order_acq_rel); }
-			inline void operator++() { ai.fetch_add(1, std::memory_order_acq_rel); }
-			inline int operator--(int) { return ai.fetch_sub(1, std::memory_order_acq_rel) - 1; }
-			inline int operator++(int) { return ai.fetch_add(1, std::memory_order_acq_rel) + 1; }
-			inline void operator-=(int i) { ai.fetch_sub(i, std::memory_order_acq_rel); }
-			inline void operator+=(int i) { ai.fetch_add(i, std::memory_order_acq_rel); }
-		private:
-			std::atomic<int> ai;
-		};
-	#else
-		class AtomicInt
-		{
-		public:
-			AtomicInt() {}
-			AtomicInt(int i) : vi(i) {}
-
-			inline operator int() const { return vi; } // Note: this isn't a guaranteed atomic operation
-			inline void operator=(const AtomicInt& i) { sw::atomicExchange(&vi, i.vi); }
-			inline void operator=(int i) { sw::atomicExchange(&vi, i); }
-			inline void operator--() { sw::atomicDecrement(&vi); }
-			inline void operator++() { sw::atomicIncrement(&vi); }
-			inline int operator--(int) { return sw::atomicDecrement(&vi); }
-			inline int operator++(int) { return sw::atomicIncrement(&vi); }
-			inline void operator-=(int i) { sw::atomicAdd(&vi, -i); }
-			inline void operator+=(int i) { sw::atomicAdd(&vi, i); }
-		private:
-			volatile int vi;
-		};
-	#endif
 }
 
 #endif   // sw_Thread_hpp
diff --git a/src/Vulkan/vulkan.vcxproj b/src/Vulkan/vulkan.vcxproj
index 60becd3..5d5b8cc 100644
--- a/src/Vulkan/vulkan.vcxproj
+++ b/src/Vulkan/vulkan.vcxproj
@@ -180,7 +180,6 @@
     <ClCompile Include="..\System\Memory.cpp" />

     <ClCompile Include="..\System\Resource.cpp" />

     <ClCompile Include="..\System\Socket.cpp" />

-    <ClCompile Include="..\System\Thread.cpp" />

     <ClCompile Include="..\System\Timer.cpp" />

     <ClCompile Include="..\WSI\VkSurfaceKHR.cpp" />

     <ClCompile Include="..\WSI\VkSwapchainKHR.cpp" />

@@ -275,7 +274,6 @@
     <ClInclude Include="..\System\Half.hpp" />

     <ClInclude Include="..\System\Math.hpp" />

     <ClInclude Include="..\System\Memory.hpp" />

-    <ClInclude Include="..\System\MutexLock.hpp" />

     <ClInclude Include="..\System\Resource.hpp" />

     <ClInclude Include="..\System\SharedLibrary.hpp" />

     <ClInclude Include="..\System\Socket.hpp" />

diff --git a/src/Vulkan/vulkan.vcxproj.filters b/src/Vulkan/vulkan.vcxproj.filters
index 98105bc..30c24be 100644
--- a/src/Vulkan/vulkan.vcxproj.filters
+++ b/src/Vulkan/vulkan.vcxproj.filters
@@ -156,9 +156,6 @@
     <ClCompile Include="..\System\Socket.cpp">

       <Filter>Source Files\System</Filter>

     </ClCompile>

-    <ClCompile Include="..\System\Thread.cpp">

-      <Filter>Source Files\System</Filter>

-    </ClCompile>

     <ClCompile Include="..\System\Timer.cpp">

       <Filter>Source Files\System</Filter>

     </ClCompile>

@@ -491,9 +488,6 @@
     <ClInclude Include="..\System\Memory.hpp">

       <Filter>Header Files\System</Filter>

     </ClInclude>

-    <ClInclude Include="..\System\MutexLock.hpp">

-      <Filter>Header Files\System</Filter>

-    </ClInclude>

     <ClInclude Include="..\System\Resource.hpp">

       <Filter>Header Files\System</Filter>

     </ClInclude>