[asterisk-scf-commits] asterisk-scf/integration/ice-util-cpp.git branch "workqueue" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Mon Mar 21 09:00:13 CDT 2011
branch "workqueue" has been updated
via b8309cfcd44dc344c2d5589e9d04eaf820827068 (commit)
from b1fe5a2bdb1df7cb951802f2944179eba62bfed8 (commit)
Summary of changes:
WorkQueue/test/TestSuspendableWorkQueue.cpp | 41 +++++++++++++--------------
1 files changed, 20 insertions(+), 21 deletions(-)
- Log -----------------------------------------------------------------
commit b8309cfcd44dc344c2d5589e9d04eaf820827068
Author: Mark Michelson <mmichelson at digium.com>
Date: Mon Mar 21 08:59:33 2011 -0500
Make the flow for the ComplexTask test less dumb.
diff --git a/WorkQueue/test/TestSuspendableWorkQueue.cpp b/WorkQueue/test/TestSuspendableWorkQueue.cpp
index e2cbf98..1ef4a85 100644
--- a/WorkQueue/test/TestSuspendableWorkQueue.cpp
+++ b/WorkQueue/test/TestSuspendableWorkQueue.cpp
@@ -22,6 +22,23 @@
using namespace AsteriskSCF::System::WorkQueue::V1;
using namespace AsteriskSCF::WorkQueue;
+// A ComplexTask creates a thread to simulate
+// An asynchronous task. When asyncTaskCond is
+// notified, this simulates the completion of
+// the asynchronous task
+static boost::condition_variable asyncTaskCond;
+static bool asyncTaskComplete;
+
+// workResumableCond is used by the ComplexTask to
+// notify the testing thread that it has
+// finished notifying the SuspendableQueue
+// that work may be resumed.
+static boost::condition_variable workResumableCond;
+
+// Lock used in conjunction with the condition
+// variables.
+static boost::mutex globalLock;
+
class TestListener : public QueueListener
{
public:
@@ -44,7 +61,9 @@ public:
void workResumable()
{
+ boost::unique_lock<boost::mutex> lock(globalLock);
resumableNotice = true;
+ workResumableCond.notify_one();
}
bool addedNotice;
@@ -69,23 +88,6 @@ public:
typedef IceUtil::Handle<SimpleTask> SimpleTaskPtr;
-// A ComplexTask creates a thread to simulate
-// An asynchronous task. When asyncTaskCond is
-// notified, this simulates the completion of
-// the asynchronous task
-static boost::condition_variable asyncTaskCond;
-static bool asyncTaskComplete;
-// workResumableCond is used by the ComplexTask to
-// notify the testing thread that it has
-// finished notifying the SuspendableQueue
-// that work may be resumed.
-static boost::condition_variable workResumableCond;
-static bool isWorkResumable;
-
-// Lock used in conjunction with the condition
-// variables.
-static boost::mutex globalLock;
-
class ComplexTask : public SuspendableWork
{
public:
@@ -127,9 +129,6 @@ public:
}
lock.unlock();
mListener->workResumable();
- lock.lock();
- isWorkResumable = true;
- workResumableCond.notify_one();
}
enum State
{
@@ -511,7 +510,7 @@ BOOST_AUTO_TEST_CASE(complexWork)
lock.unlock();
lock.lock();
- while (!isWorkResumable)
+ while (!listener->resumableNotice)
{
workResumableCond.wait(lock);
}
-----------------------------------------------------------------------
--
asterisk-scf/integration/ice-util-cpp.git
More information about the asterisk-scf-commits
mailing list