forked from GrandOrgue/grandorgue
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved the implementation of GOMutexLocker to a .cpp file
- Loading branch information
Showing
3 changed files
with
49 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright 2006 Milan Digital Audio LLC | ||
* Copyright 2009-2024 GrandOrgue contributors (see AUTHORS) | ||
* License GPL-2.0 or later | ||
* (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html). | ||
*/ | ||
|
||
#include "GOMutexLocker.h" | ||
|
||
GOMutexLocker::GOMutexLocker( | ||
GOMutex &mutex, bool try_lock, const char *lockerInfo, GOThread *pThread) | ||
: m_mutex(mutex), m_IsLocked(false) { | ||
if (try_lock) | ||
m_IsLocked = m_mutex.TryLock(lockerInfo); | ||
else if (pThread != NULL) | ||
m_IsLocked = m_mutex.LockOrStop(lockerInfo, pThread); | ||
else { | ||
m_mutex.Lock(lockerInfo); | ||
m_IsLocked = true; | ||
} | ||
} | ||
|
||
GOMutexLocker::~GOMutexLocker() { | ||
if (m_IsLocked) | ||
m_mutex.Unlock(); | ||
} | ||
|
||
bool GOMutexLocker::TryLock(const char *lockerInfo) { | ||
if (!m_IsLocked) | ||
m_IsLocked = m_mutex.TryLock(lockerInfo); | ||
return m_IsLocked; | ||
} | ||
|
||
void GOMutexLocker::Unlock() { | ||
if (m_IsLocked) | ||
m_mutex.Unlock(); | ||
m_IsLocked = false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters