diff options
Diffstat (limited to 'indra/llcommon')
-rw-r--r-- | indra/llcommon/llthreadsafequeue.h | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/indra/llcommon/llthreadsafequeue.h b/indra/llcommon/llthreadsafequeue.h index 2cee7a3141..3f49dbccc2 100644 --- a/indra/llcommon/llthreadsafequeue.h +++ b/indra/llcommon/llthreadsafequeue.h @@ -31,7 +31,7 @@ #include <deque> #include <string> #include "mutex.h" -#include <condition_variable> +#include <boost/fiber/condition_variable.hpp> // // A general queue exception. @@ -104,9 +104,9 @@ private: std::deque< ElementT > mStorage; U32 mCapacity; - std::mutex mLock; - std::condition_variable mCapacityCond; - std::condition_variable mEmptyCond; + boost::fibers::mutex mLock; + boost::fibers::condition_variable mCapacityCond; + boost::fibers::condition_variable mEmptyCond; }; // LLThreadSafeQueue @@ -122,10 +122,9 @@ mCapacity(capacity) template<typename ElementT> void LLThreadSafeQueue<ElementT>::pushFront(ElementT const & element) { + std::unique_lock<decltype(mLock)> lock1(mLock); while (true) { - std::unique_lock<std::mutex> lock1(mLock); - if (mStorage.size() < mCapacity) { mStorage.push_front(element); @@ -142,7 +141,7 @@ void LLThreadSafeQueue<ElementT>::pushFront(ElementT const & element) template<typename ElementT> bool LLThreadSafeQueue<ElementT>::tryPushFront(ElementT const & element) { - std::unique_lock<std::mutex> lock1(mLock, std::defer_lock); + std::unique_lock<decltype(mLock)> lock1(mLock, std::defer_lock); if (!lock1.try_lock()) return false; @@ -158,10 +157,9 @@ bool LLThreadSafeQueue<ElementT>::tryPushFront(ElementT const & element) template<typename ElementT> ElementT LLThreadSafeQueue<ElementT>::popBack(void) { + std::unique_lock<decltype(mLock)> lock1(mLock); while (true) { - std::unique_lock<std::mutex> lock1(mLock); - if (!mStorage.empty()) { ElementT value = mStorage.back(); @@ -179,7 +177,7 @@ ElementT LLThreadSafeQueue<ElementT>::popBack(void) template<typename ElementT> bool LLThreadSafeQueue<ElementT>::tryPopBack(ElementT & element) { - std::unique_lock<std::mutex> lock1(mLock, std::defer_lock); + std::unique_lock<decltype(mLock)> lock1(mLock, std::defer_lock); if (!lock1.try_lock()) return false; @@ -196,7 +194,7 @@ bool LLThreadSafeQueue<ElementT>::tryPopBack(ElementT & element) template<typename ElementT> size_t LLThreadSafeQueue<ElementT>::size(void) { - std::lock_guard<std::mutex> lock(mLock); + std::lock_guard<decltype(mLock)> lock(mLock); return mStorage.size(); } |