diff options
author | chai <chaifix@163.com> | 2019-07-30 22:12:11 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2019-07-30 22:12:11 +0800 |
commit | 012a44bd13ab41d056e7d3884a39027b6cea62b5 (patch) | |
tree | d835819273cdc394b5339072b887399cde3aea27 /source/modules/asura-utils/threading/semaphore.cpp | |
parent | 51a715ffe0b138960846e9f407a1290037931b33 (diff) |
*修改成员变量前缀
Diffstat (limited to 'source/modules/asura-utils/threading/semaphore.cpp')
-rw-r--r-- | source/modules/asura-utils/threading/semaphore.cpp | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/source/modules/asura-utils/threading/semaphore.cpp b/source/modules/asura-utils/threading/semaphore.cpp index aa5d9dd..7e5ccf5 100644 --- a/source/modules/asura-utils/threading/semaphore.cpp +++ b/source/modules/asura-utils/threading/semaphore.cpp @@ -10,42 +10,42 @@ namespace AsuraEngine { #define try_create_semaphore(impl) \ - if (!mImpl) \ + if (!m_Impl) \ { \ try \ { \ - mImpl = new impl(init_count); \ + m_Impl = new impl(init_count); \ } \ catch (Exception& e) \ { \ - mImpl = nullptr; \ + m_Impl = nullptr; \ } \ } Semaphore::Semaphore(unsigned int init_count) - : mImpl(nullptr) + : m_Impl(nullptr) { #ifdef ASURA_THREAD_WIN32 try_create_semaphore(SemaphoreWin32); #endif - //ASSERT(mImpl); + //ASSERT(m_Impl); } Semaphore::~Semaphore() { - if (mImpl) delete mImpl; + if (m_Impl) delete m_Impl; } void Semaphore::Signal() { - ASSERT(mImpl); - mImpl->Signal(); + ASSERT(m_Impl); + m_Impl->Signal(); } bool Semaphore::Wait(int timeout /*= ASURA_MUTEX_MAXWAIT*/) { - ASSERT(mImpl); - return mImpl->Wait(timeout); + ASSERT(m_Impl); + return m_Impl->Wait(timeout); } #if ASURA_THREAD_WIN32 @@ -54,8 +54,8 @@ namespace AsuraEngine : SemaphoreImpl(init_value) { // UINT_MAX get error. - mSem = CreateSemaphore(NULL, init_value, INT_MAX, NULL); - if (!mSem) + m_Sem = CreateSemaphore(NULL, init_value, INT_MAX, NULL); + if (!m_Sem) { int errorCode = GetLastError(); throw Exception("Cant use win32 semaphore. Error code: %d.", errorCode); @@ -64,23 +64,23 @@ namespace AsuraEngine SemaphoreWin32::~SemaphoreWin32() { - CloseHandle(mSem); + CloseHandle(m_Sem); } void SemaphoreWin32::Signal() { - InterlockedIncrement(&mCount); - if (ReleaseSemaphore(mSem, 1, NULL) == FALSE) - InterlockedDecrement(&mCount); + InterlockedIncrement(&m_Count); + if (ReleaseSemaphore(m_Sem, 1, NULL) == FALSE) + InterlockedDecrement(&m_Count); } bool SemaphoreWin32::Wait(int timeout) { int result; - result = WaitForSingleObject(mSem, timeout); + result = WaitForSingleObject(m_Sem, timeout); if (result == WAIT_OBJECT_0) { - InterlockedDecrement(&mCount); + InterlockedDecrement(&m_Count); return true; } else if(result == WAIT_TIMEOUT) |