[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
Fri Apr 8 16:56:29 CDT 2011
branch "workqueue" has been updated
via abb9e7e5a234470e1591218a514b16d93a5b8f64 (commit)
via 9c9484315e35ea79029f8ded006c59230928b851 (commit)
from 3b4d359bcd39dbe88535a89b0f19a8368fcb205a (commit)
Summary of changes:
ThreadPool/include/AsteriskSCF/ThreadPool.h | 2 +-
ThreadPool/include/AsteriskSCF/WorkerThread.h | 2 +-
ThreadPool/src/ThreadPool.cpp | 16 ++++------------
WorkQueue/src/SuspendableWorkQueue.cpp | 4 ++--
WorkQueue/src/WorkQueue.cpp | 4 ++--
WorkQueue/test/TestSuspendableWorkQueue.cpp | 2 +-
WorkQueue/test/TestWorkQueue.cpp | 9 +++++++--
7 files changed, 18 insertions(+), 21 deletions(-)
- Log -----------------------------------------------------------------
commit abb9e7e5a234470e1591218a514b16d93a5b8f64
Author: Mark Michelson <mmichelson at digium.com>
Date: Fri Apr 8 16:55:32 2011 -0500
Adjust based on change to WorkQueueIf.ice to report number of new items added to a queue.
Test code has been altered to be sure this works.
diff --git a/ThreadPool/include/AsteriskSCF/ThreadPool.h b/ThreadPool/include/AsteriskSCF/ThreadPool.h
index 4911037..9a1e662 100644
--- a/ThreadPool/include/AsteriskSCF/ThreadPool.h
+++ b/ThreadPool/include/AsteriskSCF/ThreadPool.h
@@ -42,7 +42,7 @@ class ThreadQueueListener : public AsteriskSCF::System::WorkQueue::V1::QueueList
public:
ThreadQueueListener(ThreadPoolPriv *something,
AsteriskSCF::System::ThreadPool::V1::Pool *pool);
- void workAdded(bool wasEmpty);
+ void workAdded(int numNewWork, bool wasEmpty);
void workResumable();
void emptied();
private:
diff --git a/ThreadPool/include/AsteriskSCF/WorkerThread.h b/ThreadPool/include/AsteriskSCF/WorkerThread.h
index 5fa9150..187c616 100644
--- a/ThreadPool/include/AsteriskSCF/WorkerThread.h
+++ b/ThreadPool/include/AsteriskSCF/WorkerThread.h
@@ -60,7 +60,7 @@ class WorkerThreadListener;
class WorkerThread
{
public:
- WorkerThread(int id, const AsteriskSCF::System::WorkQueue::V1::QueuePtr& workQueue, WorkerThreadListener *listener);
+ WorkerThread(const AsteriskSCF::System::WorkQueue::V1::QueuePtr& workQueue, WorkerThreadListener *listener);
void poke(ThreadState newState);
void join();
diff --git a/ThreadPool/src/ThreadPool.cpp b/ThreadPool/src/ThreadPool.cpp
index 70dede4..e5a5d99 100644
--- a/ThreadPool/src/ThreadPool.cpp
+++ b/ThreadPool/src/ThreadPool.cpp
@@ -244,17 +244,9 @@ ThreadQueueListener::ThreadQueueListener(ThreadPoolPriv *priv, Pool *pool)
{
}
-void ThreadQueueListener::workAdded(bool wasEmpty)
+void ThreadQueueListener::workAdded(int numNewWork, bool wasEmpty)
{
- // XXX The interface for PoolListener says that the second parameter of this
- // method should be the amount of new items added. Well, that's just a pain to
- // try to keep up with and report accurately. For now, I'm just going to report
- // the total work count.
- //
- // If we want to report the amount of new work, then I would strongly suggest
- // changing the QueueListener's workAdded method to include the amount of new
- // work added.
- mThreadPoolPriv->mListener->queueWorkAdded(mPool, mThreadPoolPriv->mQueue->getSize(), wasEmpty);
+ mThreadPoolPriv->mListener->queueWorkAdded(mPool, numNewWork, wasEmpty);
// XXX This could potentially stand to be more sophisticated, but poking all the
// idle threads will get the job done too.
//
diff --git a/WorkQueue/src/SuspendableWorkQueue.cpp b/WorkQueue/src/SuspendableWorkQueue.cpp
index 9db1a24..839cc1a 100644
--- a/WorkQueue/src/SuspendableWorkQueue.cpp
+++ b/WorkQueue/src/SuspendableWorkQueue.cpp
@@ -235,7 +235,7 @@ void SuspendableWorkQueue::enqueueWork(const SuspendableWorkPtr& work)
if (listenerRef != 0)
{
- listenerRef->workAdded(wasEmpty);
+ listenerRef->workAdded(1, wasEmpty);
}
}
@@ -253,7 +253,7 @@ void SuspendableWorkQueue::enqueueWorkSeq(const SuspendableWorkSeq& works)
if (listenerRef != 0)
{
- listenerRef->workAdded(wasEmpty);
+ listenerRef->workAdded(works.size(), wasEmpty);
}
}
diff --git a/WorkQueue/src/WorkQueue.cpp b/WorkQueue/src/WorkQueue.cpp
index 00b6f05..736997e 100644
--- a/WorkQueue/src/WorkQueue.cpp
+++ b/WorkQueue/src/WorkQueue.cpp
@@ -72,7 +72,7 @@ void WorkQueue::enqueueWork(const WorkPtr& work)
if (listenerRef != 0)
{
- listenerRef->workAdded(wasEmpty);
+ listenerRef->workAdded(1, wasEmpty);
}
}
@@ -89,7 +89,7 @@ void WorkQueue::enqueueWorkSeq(const WorkSeq& works)
if (listenerRef != 0)
{
- listenerRef->workAdded(wasEmpty);
+ listenerRef->workAdded(works.size(), wasEmpty);
}
}
diff --git a/WorkQueue/test/TestSuspendableWorkQueue.cpp b/WorkQueue/test/TestSuspendableWorkQueue.cpp
index b50e8eb..8c230c2 100644
--- a/WorkQueue/test/TestSuspendableWorkQueue.cpp
+++ b/WorkQueue/test/TestSuspendableWorkQueue.cpp
@@ -48,7 +48,7 @@ public:
emptyNotice(false),
resumableNotice(false) { }
- void workAdded(bool wasEmpty)
+ void workAdded(int numNewWork, bool wasEmpty)
{
addedNotice = true;
addedEmptyNotice = wasEmpty;
diff --git a/WorkQueue/test/TestWorkQueue.cpp b/WorkQueue/test/TestWorkQueue.cpp
index 7e6287a..7cbf09b 100644
--- a/WorkQueue/test/TestWorkQueue.cpp
+++ b/WorkQueue/test/TestWorkQueue.cpp
@@ -25,14 +25,15 @@ class TestListener : public QueueListener
{
public:
TestListener()
- : addedNotice(false),
+ : tasksAdded(0), addedNotice(false),
addedEmptyNotice(false),
emptyNotice(false) { }
- void workAdded(bool wasEmpty)
+ void workAdded(int numNewWork, bool wasEmpty)
{
addedNotice = true;
addedEmptyNotice = wasEmpty;
+ tasksAdded = numNewWork;
}
void emptied()
@@ -45,6 +46,7 @@ public:
BOOST_FAIL("workResumable called from a Queue?!");
}
+ int tasksAdded;
bool addedNotice;
bool addedEmptyNotice;
bool emptyNotice;
@@ -77,6 +79,7 @@ BOOST_AUTO_TEST_CASE(addWork)
BOOST_CHECK(listener->addedNotice == true);
BOOST_CHECK(listener->addedEmptyNotice == true);
+ BOOST_CHECK(listener->tasksAdded == 1);
BOOST_CHECK(queue->getSize() == 1);
}
@@ -95,6 +98,7 @@ BOOST_AUTO_TEST_CASE(addWorkSeq)
BOOST_CHECK(listener->addedNotice == true);
BOOST_CHECK(listener->addedEmptyNotice == true);
BOOST_CHECK(listener->emptyNotice == false);
+ BOOST_CHECK(listener->tasksAdded == 2);
BOOST_CHECK(queue->getSize() == 2);
}
@@ -113,6 +117,7 @@ BOOST_AUTO_TEST_CASE(appendWork)
BOOST_CHECK(listener->addedNotice == true);
BOOST_CHECK(listener->addedEmptyNotice == false);
BOOST_CHECK(listener->emptyNotice == false);
+ BOOST_CHECK(listener->tasksAdded == 1);
BOOST_CHECK(queue->getSize() == 2);
}
commit 9c9484315e35ea79029f8ded006c59230928b851
Author: Mark Michelson <mmichelson at digium.com>
Date: Thu Apr 7 22:16:23 2011 -0500
Change a parameter to a less silly name.
diff --git a/ThreadPool/src/ThreadPool.cpp b/ThreadPool/src/ThreadPool.cpp
index 6dcdfda..70dede4 100644
--- a/ThreadPool/src/ThreadPool.cpp
+++ b/ThreadPool/src/ThreadPool.cpp
@@ -239,8 +239,8 @@ public:
boost::mutex mLock;
};
-ThreadQueueListener::ThreadQueueListener(ThreadPoolPriv *something, Pool *pool)
- : mThreadPoolPriv(something), mPool(pool)
+ThreadQueueListener::ThreadQueueListener(ThreadPoolPriv *priv, Pool *pool)
+ : mThreadPoolPriv(priv), mPool(pool)
{
}
-----------------------------------------------------------------------
--
asterisk-scf/integration/ice-util-cpp.git
More information about the asterisk-scf-commits
mailing list