diff options
Diffstat (limited to 'FoundationEx/ThreadSync.h')
-rw-r--r-- | FoundationEx/ThreadSync.h | 56 |
1 files changed, 0 insertions, 56 deletions
diff --git a/FoundationEx/ThreadSync.h b/FoundationEx/ThreadSync.h deleted file mode 100644 index ccf79f4..0000000 --- a/FoundationEx/ThreadSync.h +++ /dev/null @@ -1,56 +0,0 @@ -/* Starshatter: The Open Source Project - Copyright (c) 2021-2022, Starshatter: The Open Source Project Contributors - Copyright (c) 2011-2012, Starshatter OpenSource Distribution Contributors - Copyright (c) 1997-2006, Destroyer Studios LLC. - - AUTHOR: John DiCamillo - - - OVERVIEW - ======== - Declaration of the ThreadSync class -*/ - -#ifndef ThreadSync_h -#define ThreadSync_h - -#include <windows.h> - -// +-------------------------------------------------------------------+ - -class ThreadSync -{ -#if defined(_MT) // MULTITHREADED: WITH SYNC ------------ - CRITICAL_SECTION sync; - -public: - ThreadSync() { ::InitializeCriticalSection(&sync); } - ~ThreadSync() { ::DeleteCriticalSection(&sync); } - - void acquire() { ::EnterCriticalSection(&sync); } - void release() { ::LeaveCriticalSection(&sync); } - -#else // SINGLE THREADED: NO SYNC ------------ - -public: - ThreadSync() { } - ~ThreadSync() { } - - void acquire() { } - void release() { } - -#endif -}; - -// +-------------------------------------------------------------------+ - -class AutoThreadSync -{ -public: - AutoThreadSync(ThreadSync& s) : sync(s) { sync.acquire(); } - ~AutoThreadSync() { sync.release(); } -private: - ThreadSync& sync; -}; - -#endif // ThreadSync_h |