From 0e0a1ae0207f0faa41f82bc4544708143e99db7b Mon Sep 17 00:00:00 2001 From: Patrik Gornicz Date: Mon, 18 May 2009 01:42:43 -0400 Subject: [PATCH] renamed Mutex to Lock ... --- inc/Autolock.h | 12 ++++++------ inc/Lock.h | 24 ++++++++++++------------ inc/debug.h | 2 +- src/debug.cpp | 10 +++++----- src/locks/Autolock.cpp | 18 +++++++++--------- src/locks/Lock.cpp | 22 +++++++++------------- src/locks/dir.mk | 2 +- 7 files changed, 43 insertions(+), 47 deletions(-) diff --git a/inc/Autolock.h b/inc/Autolock.h index c18b590..b5d99ca 100644 --- a/inc/Autolock.h +++ b/inc/Autolock.h @@ -23,17 +23,17 @@ namespace pg { - class Mutex; + class Lock; /// ***** Header Class ***** class Autolock { public: - Autolock(Mutex& mu); - ~Autolock(); + Autolock(Lock* plock); // LOCKS + ~Autolock(); // UNLOCKS - void Lock(); - void Unlock(); + void lock(); + void unlock(); // hide copying methods! private: @@ -41,7 +41,7 @@ namespace pg const Autolock& operator ==(const Autolock&); private: - Mutex& m_mu; + Lock* m_plock; }; } // namespace pg diff --git a/inc/Lock.h b/inc/Lock.h index aa17d98..89a3f65 100644 --- a/inc/Lock.h +++ b/inc/Lock.h @@ -16,8 +16,8 @@ */ -#ifndef MUTEX_H -#define MUTEX_H +#ifndef LOCK_H +#define LOCK_H class SDL_mutex; @@ -27,24 +27,24 @@ namespace pg /// ***** Header Class ***** - class Mutex + class Lock { public: - Mutex(); - ~Mutex(); + Lock(); + ~Lock() {} void init(); - void deinit(); + void fini(); - bool IsValid(); + bool isValid(); - void Lock(); - void Unlock(); + void lock(); + void unlock(); // hide copying methods! private: - Mutex(const Mutex&); - const Mutex& operator ==(const Mutex&); + Lock(const Lock&); + const Lock& operator ==(const Lock&); private: SDL_mutex* m_pSDL_mutex; @@ -54,4 +54,4 @@ namespace pg } // namespace pg -#endif // MUTEX_H +#endif // LOCK_H diff --git a/inc/debug.h b/inc/debug.h index 676cb6b..66857fc 100644 --- a/inc/debug.h +++ b/inc/debug.h @@ -25,7 +25,7 @@ namespace pg namespace debug { void init(); - void deinit(); + void fini(); } void DASSERT(bool fAssert); diff --git a/src/debug.cpp b/src/debug.cpp index f96795c..490ec81 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -24,7 +24,7 @@ using std::endl; #include -#include "Mutex.h" +#include "Lock.h" #include "Autolock.h" using namespace pg; @@ -32,11 +32,11 @@ using namespace pg; /// ***** Public Methods ***** -Mutex muDPF; +Lock muDPF; void pg::DPF(int iLevel, const char* pstr) { - Autolock lock(muDPF); + Autolock lock(&muDPF); cout << pstr << endl; } @@ -46,9 +46,9 @@ void pg::debug::init() muDPF.init(); } -void pg::debug::deinit() +void pg::debug::fini() { - muDPF.deinit(); + muDPF.fini(); } void pg::DASSERT(bool fAssert) diff --git a/src/locks/Autolock.cpp b/src/locks/Autolock.cpp index 2cf048d..5bc4120 100644 --- a/src/locks/Autolock.cpp +++ b/src/locks/Autolock.cpp @@ -17,29 +17,29 @@ #include "Autolock.h" -#include "Mutex.h" +#include "Lock.h" using namespace pg; /// ***** Constructors/Destructors ***** -Autolock::Autolock(Mutex& mu) - : m_mu(mu) +Autolock::Autolock(Lock* plock) + : m_plock(plock) { - Lock(); + lock(); } Autolock::~Autolock() { - Unlock(); + unlock(); } -void Autolock::Lock() +void Autolock::lock() { - m_mu.Lock(); + m_plock->lock(); } -void Autolock::Unlock() +void Autolock::unlock() { - m_mu.Unlock(); + m_plock->unlock(); } diff --git a/src/locks/Lock.cpp b/src/locks/Lock.cpp index c419b86..9204896 100644 --- a/src/locks/Lock.cpp +++ b/src/locks/Lock.cpp @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -#include "Mutex.h" +#include "Lock.h" #include "debug.h" #include @@ -23,41 +23,37 @@ using namespace pg; -Mutex::Mutex() +Lock::Lock() : m_pSDL_mutex(NULL) { } -Mutex::~Mutex() -{ - -} -void Mutex::init() +void Lock::init() { m_pSDL_mutex = SDL_CreateMutex(); } -void Mutex::deinit() +void Lock::fini() { SDL_DestroyMutex(m_pSDL_mutex); m_pSDL_mutex = NULL; } -bool Mutex::IsValid() +bool Lock::isValid() { return NULL != m_pSDL_mutex; } -void Mutex::Lock() +void Lock::lock() { - DASSERT(IsValid()); + DASSERT(isValid()); SDL_mutexP(m_pSDL_mutex); m_uiThreadID = SDL_ThreadID(); } -void Mutex::Unlock() +void Lock::unlock() { - DASSERT(IsValid()); + DASSERT(isValid()); DASSERT(m_uiThreadID == SDL_ThreadID()); SDL_mutexV(m_pSDL_mutex); diff --git a/src/locks/dir.mk b/src/locks/dir.mk index f7e8b9e..7a6068d 100644 --- a/src/locks/dir.mk +++ b/src/locks/dir.mk @@ -1,7 +1,7 @@ NEWSRCS := # insure blank NEWSRCS += Autolock.cpp -NEWSRCS += Mutex.cpp +NEWSRCS += Lock.cpp # Post dir setup -- 2.10.2