From: <sv...@ww...> - 2005-12-11 05:57:07
|
Author: mkrose Date: 2005-12-10 21:56:56 -0800 (Sat, 10 Dec 2005) New Revision: 1745 Modified: trunk/CSP/csp/csplib/thread/Synchronization.h trunk/CSP/csp/csplib/thread/ThreadQueue.h Log: Comment out the Conditional wrapper since cc++ does not implement it on win32. Clean up ThreadQueue to use the new synchronization wrappers, but since it relies on Conditional it is not currently usable. Browse at: https://www.zerobar.net/viewcvs/viewcvs.cgi?view=rev&rev=1745 Modified: trunk/CSP/csp/csplib/thread/Synchronization.h =================================================================== --- trunk/CSP/csp/csplib/thread/Synchronization.h 2005-12-10 20:01:31 UTC (rev 1744) +++ trunk/CSP/csp/csplib/thread/Synchronization.h 2005-12-11 05:56:56 UTC (rev 1745) @@ -146,6 +146,13 @@ }; +// CC++ does not yet implement Conditional on win32, so it has been disabled +// here. For more information on the difficulty of implementing condition +// variables using win32 threading primitives, see +// http://www.cs.wustl.edu/~schmidt/win32-cv-1.html and +// http://www.cs.wustl.edu/~schmidt/win32-cv-2.html + +#if 0 /** Thin wrapper for cc++ Conditional. Condition variables provide a signaling * mechanism to synchronize multiple threads. Each condition variable is * associated with a mutex. A thread first locks the mutex, then waits on the @@ -207,6 +214,9 @@ private: ost::Conditional m_cond; }; +#else +class CSP_EXPORT Conditional {}; +#endif /** A thin wrapper around cc++ Event. Modified: trunk/CSP/csp/csplib/thread/ThreadQueue.h =================================================================== --- trunk/CSP/csp/csplib/thread/ThreadQueue.h 2005-12-10 20:01:31 UTC (rev 1744) +++ trunk/CSP/csp/csplib/thread/ThreadQueue.h 2005-12-11 05:56:56 UTC (rev 1745) @@ -73,7 +73,7 @@ m_notFull.unlock(); throw Full(); } - m_notFull.wait(); + m_notFull.wait(0, true); } pushItem(item); m_notFull.unlock(); @@ -94,7 +94,7 @@ m_notEmpty.unlock(); return false; } - m_notEmpty.wait(); + m_notEmpty.wait(0, true); } item = popItem(); m_notEmpty.unlock(); @@ -112,7 +112,7 @@ bool get(TYPE &item, double timeout) { m_notEmpty.lock(); while (empty()) { - if (!m_notEmpty.wait(timeout)) { + if (!m_notEmpty.wait(timeout, true)) { m_notEmpty.unlock(); return false; } @@ -128,8 +128,7 @@ * * @param maxsize the upper limit on the size of the queue; or zero for no limit. */ - ThreadSafeQueueBase(int maxsize) - : m_mutex(), m_notEmpty(m_mutex), m_notFull(m_mutex), m_maxsize(maxsize) {} + ThreadSafeQueueBase(int maxsize): m_maxsize(maxsize) {} /** Destructor. */ @@ -144,9 +143,8 @@ virtual TYPE popItem() = 0; private: - ThreadMutex m_mutex; - ThreadCondition m_notEmpty; - ThreadCondition m_notFull; + Conditional m_notEmpty; + Conditional m_notFull; int m_maxsize; }; |