diff options
author | Oz Linden <oz@lindenlab.com> | 2012-10-10 21:40:10 -0400 |
---|---|---|
committer | Oz Linden <oz@lindenlab.com> | 2012-10-10 21:40:10 -0400 |
commit | 1709952adbb3ad3ba4eb7d5be39c0c67c389c7c5 (patch) | |
tree | ad71b6021639d4d9d89c9992aff13f000dd0248f /indra/llcommon/llthread.h | |
parent | cb5a0a5686799ec834f16a0bc273d24f62140753 (diff) | |
parent | 3f45fa719e4c72e528801d4d8330a114e5458f30 (diff) |
pull back 3.4.1-beta6 fixes
Diffstat (limited to 'indra/llcommon/llthread.h')
-rw-r--r-- | indra/llcommon/llthread.h | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/indra/llcommon/llthread.h b/indra/llcommon/llthread.h index b52e70ab2e..115bf47553 100644 --- a/indra/llcommon/llthread.h +++ b/indra/llcommon/llthread.h @@ -97,6 +97,7 @@ private: protected: std::string mName; LLCondition* mRunCondition; + LLMutex* mDataLock; apr_thread_t *mAPRThreadp; apr_pool_t *mAPRPoolp; @@ -122,15 +123,15 @@ protected: inline void unlockData(); // This is the predicate that decides whether the thread should sleep. - // It should only be called with mRunCondition locked, since the virtual runCondition() function may need to access + // It should only be called with mDataLock locked, since the virtual runCondition() function may need to access // data structures that are thread-unsafe. bool shouldSleep(void) { return (mStatus == RUNNING) && (isPaused() || (!runCondition())); } // To avoid spurious signals (and the associated context switches) when the condition may or may not have changed, you can do the following: - // mRunCondition->lock(); + // mDataLock->lock(); // if(!shouldSleep()) // mRunCondition->signal(); - // mRunCondition->unlock(); + // mDataLock->unlock(); }; //============================================================================ @@ -205,12 +206,12 @@ private: void LLThread::lockData() { - mRunCondition->lock(); + mDataLock->lock(); } void LLThread::unlockData() { - mRunCondition->unlock(); + mDataLock->unlock(); } @@ -227,15 +228,27 @@ public: private: static LLMutex* sMutex; -private: - LLThreadSafeRefCount(const LLThreadSafeRefCount&); // not implemented - LLThreadSafeRefCount&operator=(const LLThreadSafeRefCount&); // not implemented - protected: virtual ~LLThreadSafeRefCount(); // use unref() public: LLThreadSafeRefCount(); + LLThreadSafeRefCount(const LLThreadSafeRefCount&); + LLThreadSafeRefCount& operator=(const LLThreadSafeRefCount& ref) + { + if (sMutex) + { + sMutex->lock(); + } + mRef = 0; + if (sMutex) + { + sMutex->unlock(); + } + return *this; + } + + void ref() { |