[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
Thu Mar 31 13:10:27 CDT 2011


branch "workqueue" has been updated
       via  7e5feff45ffbf9a7c76b8f6f3479f94644a204dd (commit)
       via  8227c566d0fd8ae6dfb1860b01973bbc8784a69c (commit)
      from  894bfb514ff55ea84a7ac6294a037a579b45292e (commit)

Summary of changes:
 .../include/AsteriskSCF/SuspendableWorkQueue.h     |    5 +-
 WorkQueue/include/AsteriskSCF/WorkQueue.h          |    5 +-
 WorkQueue/src/SuspendableWorkQueue.cpp             |   51 +-------
 WorkQueue/src/WorkQueue.cpp                        |   31 +-----
 WorkQueue/test/TestSuspendableWorkQueue.cpp        |  122 +++-----------------
 WorkQueue/test/TestWorkQueue.cpp                   |  110 ++----------------
 6 files changed, 46 insertions(+), 278 deletions(-)


- Log -----------------------------------------------------------------
commit 7e5feff45ffbf9a7c76b8f6f3479f94644a204dd
Author: Mark Michelson <mmichelson at digium.com>
Date:   Thu Mar 31 13:09:35 2011 -0500

    Add some documentation for return value of executeWork() methods.

diff --git a/WorkQueue/include/AsteriskSCF/SuspendableWorkQueue.h b/WorkQueue/include/AsteriskSCF/SuspendableWorkQueue.h
index df6b97d..4b2387c 100644
--- a/WorkQueue/include/AsteriskSCF/SuspendableWorkQueue.h
+++ b/WorkQueue/include/AsteriskSCF/SuspendableWorkQueue.h
@@ -35,6 +35,9 @@ public:
     void enqueueWork(const AsteriskSCF::System::WorkQueue::V1::SuspendableWorkPtr& work);
     void enqueueWorkSeq(const AsteriskSCF::System::WorkQueue::V1::SuspendableWorkSeq& works);
     void cancelWork(const AsteriskSCF::System::WorkQueue::V1::SuspendableWorkPtr& work);
+    /**
+     * Return value indicates if there is more work that can be handled immediately.
+     */
     bool executeWork();
     int getSize();
     void setListener(const AsteriskSCF::System::WorkQueue::V1::QueueListenerPtr& listener);
diff --git a/WorkQueue/include/AsteriskSCF/WorkQueue.h b/WorkQueue/include/AsteriskSCF/WorkQueue.h
index 82dd262..2ebdeaf 100644
--- a/WorkQueue/include/AsteriskSCF/WorkQueue.h
+++ b/WorkQueue/include/AsteriskSCF/WorkQueue.h
@@ -34,6 +34,9 @@ public:
     void enqueueWork(const AsteriskSCF::System::WorkQueue::V1::WorkPtr& work);
     void enqueueWorkSeq(const AsteriskSCF::System::WorkQueue::V1::WorkSeq& works);
     void cancelWork(const AsteriskSCF::System::WorkQueue::V1::WorkPtr& work);
+    /**
+     * Return value indicates if there is more work that can be executed immediately.
+     */
     bool executeWork();
     int getSize();
     void setListener(const AsteriskSCF::System::WorkQueue::V1::QueueListenerPtr& listener);

commit 8227c566d0fd8ae6dfb1860b01973bbc8784a69c
Author: Mark Michelson <mmichelson at digium.com>
Date:   Thu Mar 31 13:04:33 2011 -0500

    Address review feedback from Ken and Joshua.
    
    * Change name of workCount() to getSize() for queues.
    * Remove WorkExists and SuspendableWorkExists exceptions.
    * Decapitate a goat
    * Remove unnecessary cout statements from tests.
    
    Tests still pass.

diff --git a/WorkQueue/include/AsteriskSCF/SuspendableWorkQueue.h b/WorkQueue/include/AsteriskSCF/SuspendableWorkQueue.h
index 3f08353..df6b97d 100644
--- a/WorkQueue/include/AsteriskSCF/SuspendableWorkQueue.h
+++ b/WorkQueue/include/AsteriskSCF/SuspendableWorkQueue.h
@@ -36,7 +36,7 @@ public:
     void enqueueWorkSeq(const AsteriskSCF::System::WorkQueue::V1::SuspendableWorkSeq& works);
     void cancelWork(const AsteriskSCF::System::WorkQueue::V1::SuspendableWorkPtr& work);
     bool executeWork();
-    int workCount();
+    int getSize();
     void setListener(const AsteriskSCF::System::WorkQueue::V1::QueueListenerPtr& listener);
 private:
     boost::shared_ptr<SuspendableWorkQueuePriv> mPriv;
diff --git a/WorkQueue/include/AsteriskSCF/WorkQueue.h b/WorkQueue/include/AsteriskSCF/WorkQueue.h
index 04e8a08..82dd262 100644
--- a/WorkQueue/include/AsteriskSCF/WorkQueue.h
+++ b/WorkQueue/include/AsteriskSCF/WorkQueue.h
@@ -35,7 +35,7 @@ public:
     void enqueueWorkSeq(const AsteriskSCF::System::WorkQueue::V1::WorkSeq& works);
     void cancelWork(const AsteriskSCF::System::WorkQueue::V1::WorkPtr& work);
     bool executeWork();
-    int workCount();
+    int getSize();
     void setListener(const AsteriskSCF::System::WorkQueue::V1::QueueListenerPtr& listener);
 private:
     boost::shared_ptr<WorkQueuePriv> mPriv;
diff --git a/WorkQueue/src/SuspendableWorkQueue.cpp b/WorkQueue/src/SuspendableWorkQueue.cpp
index f70c3e4..fdb6a60 100644
--- a/WorkQueue/src/SuspendableWorkQueue.cpp
+++ b/WorkQueue/src/SuspendableWorkQueue.cpp
@@ -37,46 +37,11 @@ public:
     /**
      * mLock is expected to be held when this function is called
      */
-    int workCount()
+    int getSize()
     {
         return mQueue.size() + (currentWork == 0 ? 0 : 1);
     }
 
-    void findDuplicates(const SuspendableWorkSeq& newItems)
-    {
-        SuspendableWorkSeq dupItems;
-        {
-            boost::shared_lock<boost::shared_mutex> lock(mLock);
-
-            if (workCount() == 0)
-            {
-                return;
-            }
-
-            for (SuspendableWorkSeq::const_iterator iter = newItems.begin();
-                    iter != newItems.end(); ++iter)
-            {
-                if (*iter == currentWork ||
-                        std::find(mQueue.begin(), mQueue.end(), *iter) != mQueue.end())
-                {
-                    dupItems.push_back(*iter);
-                }
-            }
-        }
-
-        if (!dupItems.empty())
-        {
-            throw SuspendableWorkExists(__FILE__, __LINE__, dupItems);
-        }
-    }
-
-    void findDuplicates(const SuspendableWorkPtr &item)
-    {
-        SuspendableWorkSeq items;
-        items.push_back(item);
-        findDuplicates(items);
-    }
-
     SuspendableWorkPtr getNextTask()
     {
         boost::unique_lock<boost::shared_mutex> lock(mLock);
@@ -125,7 +90,7 @@ public:
          * * Executing: When a work item's execute method
          *   returns Complete
          * * Resumable: When a work item's execute method
-         *   returns Suspended.
+         *   returns Complete.
          *
          * Transitions from this state:
          * * Executing: When a work item is executed
@@ -257,14 +222,12 @@ SuspendableWorkQueue::SuspendableWorkQueue(const QueueListenerPtr& listener)
 
 void SuspendableWorkQueue::enqueueWork(const SuspendableWorkPtr& work)
 {
-    mPriv->findDuplicates(work);
-
     bool wasEmpty;
     QueueListenerPtr listenerRef;
     {
         boost::unique_lock<boost::shared_mutex> lock(mPriv->mLock);
         //Call private version so we don't double grab the lock
-        wasEmpty = mPriv->workCount() == 0; 
+        wasEmpty = mPriv->getSize() == 0; 
         mPriv->mQueue.push_back(work);
         listenerRef = mPriv->mListener;
     }
@@ -277,14 +240,12 @@ void SuspendableWorkQueue::enqueueWork(const SuspendableWorkPtr& work)
 
 void SuspendableWorkQueue::enqueueWorkSeq(const SuspendableWorkSeq& works)
 {
-    mPriv->findDuplicates(works);
-
     bool wasEmpty;
     QueueListenerPtr listenerRef;
     {
         boost::unique_lock<boost::shared_mutex> lock(mPriv->mLock);
         //Call private version so we don't double grab the lock
-        wasEmpty = mPriv->workCount() == 0;
+        wasEmpty = mPriv->getSize() == 0;
         mPriv->mQueue.insert(mPriv->mQueue.end(), works.begin(), works.end());
         listenerRef = mPriv->mListener;
     }
@@ -384,10 +345,10 @@ bool SuspendableWorkQueue::executeWork()
     return true;
 }
 
-int SuspendableWorkQueue::workCount()
+int SuspendableWorkQueue::getSize()
 {
     boost::shared_lock<boost::shared_mutex> lock(mPriv->mLock);
-    return mPriv->workCount();
+    return mPriv->getSize();
 }
 
 void SuspendableWorkQueue::setListener(const QueueListenerPtr& listener)
diff --git a/WorkQueue/src/WorkQueue.cpp b/WorkQueue/src/WorkQueue.cpp
index 458612a..7e99198 100644
--- a/WorkQueue/src/WorkQueue.cpp
+++ b/WorkQueue/src/WorkQueue.cpp
@@ -34,31 +34,6 @@ public:
     WorkQueuePriv(const QueueListenerPtr& listener)
         : mListener(listener) { }
 
-    void findDuplicates(const WorkSeq &works)
-    {
-        boost::shared_lock<boost::shared_mutex> lock(mLock);
-        WorkSeq exceptionItems;
-        for (WorkSeq::const_iterator iter = works.begin(); iter != works.end(); ++iter)
-        {
-            if (std::find(mQueue.begin(), mQueue.end(), *iter) != mQueue.end())
-            {
-                exceptionItems.push_back(*iter);
-            }
-        }
-    
-        if (!exceptionItems.empty())
-        {
-            throw WorkExists(__FILE__, __LINE__, exceptionItems);
-        }
-    }
-
-    void findDuplicates(const WorkPtr &work)
-    {
-        WorkSeq items;
-        items.push_back(work);
-        findDuplicates(items);
-    }
-
     WorkPtr getNextTask()
     {
         boost::unique_lock<boost::shared_mutex> lock(mLock);
@@ -85,8 +60,6 @@ WorkQueue::WorkQueue(const QueueListenerPtr& listener)
 
 void WorkQueue::enqueueWork(const WorkPtr& work)
 {
-    mPriv->findDuplicates(work);
-
     bool wasEmpty;
     QueueListenerPtr listenerRef;
     {
@@ -104,8 +77,6 @@ void WorkQueue::enqueueWork(const WorkPtr& work)
 
 void WorkQueue::enqueueWorkSeq(const WorkSeq& works)
 {
-    mPriv->findDuplicates(works);
-
     bool wasEmpty;
     QueueListenerPtr listenerRef;
     {
@@ -173,7 +144,7 @@ bool WorkQueue::executeWork()
     return true;
 }
 
-int WorkQueue::workCount()
+int WorkQueue::getSize()
 {
     boost::shared_lock<boost::shared_mutex> lock(mPriv->mLock);
     return mPriv->mQueue.size();
diff --git a/WorkQueue/test/TestSuspendableWorkQueue.cpp b/WorkQueue/test/TestSuspendableWorkQueue.cpp
index d4b26d6..b50e8eb 100644
--- a/WorkQueue/test/TestSuspendableWorkQueue.cpp
+++ b/WorkQueue/test/TestSuspendableWorkQueue.cpp
@@ -185,20 +185,11 @@ BOOST_AUTO_TEST_CASE(addWork)
     SuspendableQueuePtr queue(new SuspendableWorkQueue(listener));
     SimpleTaskPtr work(new SimpleTask);
 
-    bool excepted = false;
-    try
-    {
-        queue->enqueueWork(work);
-    }
-    catch (const SuspendableWorkExists& )
-    {
-        excepted = true;
-    }
+    queue->enqueueWork(work);
 
-    BOOST_CHECK(excepted == false);
     BOOST_CHECK(listener->addedNotice == true);
     BOOST_CHECK(listener->addedEmptyNotice == true);
-    BOOST_CHECK(queue->workCount() == 1);
+    BOOST_CHECK(queue->getSize() == 1);
 }
 
 BOOST_AUTO_TEST_CASE(addWorkSeq)
@@ -211,21 +202,12 @@ BOOST_AUTO_TEST_CASE(addWorkSeq)
     works.push_back(work1);
     works.push_back(work2);
 
-    bool excepted = false;
-    try
-    {
-        queue->enqueueWorkSeq(works);
-    }
-    catch (const SuspendableWorkExists& )
-    {
-        excepted = true;
-    }
+    queue->enqueueWorkSeq(works);
 
-    BOOST_CHECK(excepted == false);
     BOOST_CHECK(listener->addedNotice == true);
     BOOST_CHECK(listener->addedEmptyNotice == true);
     BOOST_CHECK(listener->emptyNotice == false);
-    BOOST_CHECK(queue->workCount() == 2);
+    BOOST_CHECK(queue->getSize() == 2);
 }
 
 BOOST_AUTO_TEST_CASE(appendWork)
@@ -238,78 +220,12 @@ BOOST_AUTO_TEST_CASE(appendWork)
     queue->enqueueWork(work1);
     listener->addedNotice = false;
 
-    bool excepted = false;
-    try
-    {
-        queue->enqueueWork(work2);
-    }
-    catch (const SuspendableWorkExists& )
-    {
-        excepted = true;
-    }
+    queue->enqueueWork(work2);
 
-    BOOST_CHECK(excepted == false);
     BOOST_CHECK(listener->addedNotice == true);
     BOOST_CHECK(listener->addedEmptyNotice == false);
     BOOST_CHECK(listener->emptyNotice == false);
-    BOOST_CHECK(queue->workCount() == 2);
-}
-
-BOOST_AUTO_TEST_CASE(addExistentWork)
-{
-    TestListenerPtr listener(new TestListener);
-    SuspendableQueuePtr queue(new SuspendableWorkQueue(listener));
-    SimpleTaskPtr work(new SimpleTask);
-
-    queue->enqueueWork(work);
-
-    bool excepted = false;
-    try
-    {
-        queue->enqueueWork(work);
-    }
-    catch(const SuspendableWorkExists& error)
-    {
-        excepted = true;
-        BOOST_CHECK(error.items.front() == work);
-    }
-
-    BOOST_CHECK(excepted == true);
-    BOOST_CHECK(queue->workCount() == 1);
-}
-
-BOOST_AUTO_TEST_CASE(addExistentWorkSeq)
-{
-    TestListenerPtr listener(new TestListener);
-    SuspendableQueuePtr queue(new SuspendableWorkQueue(listener));
-    SimpleTaskPtr work1(new SimpleTask);
-    SimpleTaskPtr work2(new SimpleTask);
-    SimpleTaskPtr work3(new SimpleTask);
-    SuspendableWorkSeq works1;
-    SuspendableWorkSeq works2;
-    works1.push_back(work1);
-    works1.push_back(work2);
-    works2.push_back(work3);
-    works2.push_back(work2);
-    
-    queue->enqueueWorkSeq(works1);
-
-    bool excepted = false;
-    try
-    {
-        queue->enqueueWorkSeq(works2);
-    }
-    catch (const SuspendableWorkExists& error)
-    {
-        excepted = true;
-        BOOST_CHECK(error.items.front() == work2);
-    }
-
-    BOOST_CHECK(excepted == true);
-    BOOST_CHECK(listener->addedNotice == true);
-    BOOST_CHECK(listener->addedEmptyNotice == true);
-    BOOST_CHECK(listener->emptyNotice == false);
-    BOOST_CHECK(queue->workCount() == 2);
+    BOOST_CHECK(queue->getSize() == 2);
 }
 
 BOOST_AUTO_TEST_CASE(cancelWork)
@@ -332,7 +248,7 @@ BOOST_AUTO_TEST_CASE(cancelWork)
 
     BOOST_CHECK(excepted == false);
     BOOST_CHECK(listener->emptyNotice == true);
-    BOOST_CHECK(queue->workCount() == 0);
+    BOOST_CHECK(queue->getSize() == 0);
 }
 
 BOOST_AUTO_TEST_CASE(cancelNonExistent1)
@@ -355,7 +271,7 @@ BOOST_AUTO_TEST_CASE(cancelNonExistent1)
     BOOST_CHECK(listener->addedNotice == false);
     BOOST_CHECK(listener->addedEmptyNotice == false);
     BOOST_CHECK(listener->emptyNotice == false);
-    BOOST_CHECK(queue->workCount() == 0);
+    BOOST_CHECK(queue->getSize() == 0);
 }
 
 BOOST_AUTO_TEST_CASE(cancelNonExistent2)
@@ -378,7 +294,7 @@ BOOST_AUTO_TEST_CASE(cancelNonExistent2)
     }
 
     BOOST_CHECK(excepted == true);
-    BOOST_CHECK(queue->workCount() == 1);
+    BOOST_CHECK(queue->getSize() == 1);
 }
 
 BOOST_AUTO_TEST_CASE(simpleWorkExecution)
@@ -393,7 +309,7 @@ BOOST_AUTO_TEST_CASE(simpleWorkExecution)
     BOOST_CHECK(moreWork == false);
     BOOST_CHECK(work->taskExecuted == true);
     BOOST_CHECK(listener->emptyNotice == true);
-    BOOST_CHECK(queue->workCount() == 0);
+    BOOST_CHECK(queue->getSize() == 0);
 }
 
 BOOST_AUTO_TEST_CASE(executeNonExistent)
@@ -404,7 +320,7 @@ BOOST_AUTO_TEST_CASE(executeNonExistent)
     bool moreWork = queue->executeWork();
 
     BOOST_CHECK(moreWork == false);
-    BOOST_CHECK(queue->workCount() == 0);
+    BOOST_CHECK(queue->getSize() == 0);
     BOOST_CHECK(listener->emptyNotice == false);
 }
 
@@ -429,7 +345,7 @@ BOOST_AUTO_TEST_CASE(executionOrder1)
     BOOST_CHECK(moreWork == false);
     BOOST_CHECK(work2->taskExecuted == true);
     BOOST_CHECK(listener->emptyNotice == true);
-    BOOST_CHECK(queue->workCount() == 0);
+    BOOST_CHECK(queue->getSize() == 0);
 }
 
 BOOST_AUTO_TEST_CASE(executionOrder2)
@@ -477,7 +393,7 @@ BOOST_AUTO_TEST_CASE(executionOrder2)
     BOOST_CHECK(moreWork == false);
     BOOST_CHECK(work4->taskExecuted == true);
     BOOST_CHECK(listener->emptyNotice == true);
-    BOOST_CHECK(queue->workCount() == 0);
+    BOOST_CHECK(queue->getSize() == 0);
 }
 
 // Begin unique SuspendableWorkQueue tests
@@ -493,7 +409,7 @@ BOOST_AUTO_TEST_CASE(complexWork)
     bool moreWork = queue->executeWork();
 
     BOOST_CHECK(moreWork == false);
-    BOOST_CHECK(queue->workCount() == 1);
+    BOOST_CHECK(queue->getSize() == 1);
     BOOST_CHECK(work->currentState == ComplexTask::Task1Complete);
 
     //Until we poke the ComplexTask's thread, the queue
@@ -502,7 +418,7 @@ BOOST_AUTO_TEST_CASE(complexWork)
     moreWork = queue->executeWork();
 
     BOOST_CHECK(moreWork == false);
-    BOOST_CHECK(queue->workCount() == 1);
+    BOOST_CHECK(queue->getSize() == 1);
     BOOST_CHECK(work->currentState == ComplexTask::Task1Complete);
 
     // We simulate the ComplexTask's asynchronous task here in
@@ -528,9 +444,7 @@ BOOST_AUTO_TEST_CASE(complexWork)
     moreWork = queue->executeWork();
 
     BOOST_CHECK(moreWork == false);
-    std::cout << "Work count is " << queue->workCount() << std::endl;
-    BOOST_CHECK(queue->workCount() == 0);
-    std::cout << "State of work is " << work->currentState << std::endl;
+    BOOST_CHECK(queue->getSize() == 0);
     BOOST_CHECK(work->currentState == ComplexTask::Task2Complete);
     BOOST_CHECK(listener->emptyNotice == true);
 }
@@ -548,7 +462,7 @@ BOOST_AUTO_TEST_CASE(racyWork)
     BOOST_CHECK(moreWork == true);
     BOOST_CHECK(listener->resumableNotice == false);
     BOOST_CHECK(work->currentState == RacyTask::Task1Complete);
-    BOOST_CHECK(queue->workCount() == 1);
+    BOOST_CHECK(queue->getSize() == 1);
     BOOST_CHECK(listener->emptyNotice == false);
 
     //Because the queue was already told work was resumable,
@@ -558,7 +472,7 @@ BOOST_AUTO_TEST_CASE(racyWork)
 
     BOOST_CHECK(moreWork == false);
     BOOST_CHECK(work->currentState == RacyTask::Task2Complete);
-    BOOST_CHECK(queue->workCount() == 0);
+    BOOST_CHECK(queue->getSize() == 0);
     BOOST_CHECK(listener->emptyNotice == true);
 }
 
diff --git a/WorkQueue/test/TestWorkQueue.cpp b/WorkQueue/test/TestWorkQueue.cpp
index ef20a70..7e6287a 100644
--- a/WorkQueue/test/TestWorkQueue.cpp
+++ b/WorkQueue/test/TestWorkQueue.cpp
@@ -73,20 +73,11 @@ BOOST_AUTO_TEST_CASE(addWork)
     QueuePtr queue(new WorkQueue(listener));
     TaskPtr work(new Task);
 
-    bool excepted = false;
-    try
-    {
-        queue->enqueueWork(work);
-    }
-    catch (const WorkExists& )
-    {
-        excepted = true;
-    }
+    queue->enqueueWork(work);
 
-    BOOST_CHECK(excepted == false);
     BOOST_CHECK(listener->addedNotice == true);
     BOOST_CHECK(listener->addedEmptyNotice == true);
-    BOOST_CHECK(queue->workCount() == 1);
+    BOOST_CHECK(queue->getSize() == 1);
 }
 
 BOOST_AUTO_TEST_CASE(addWorkSeq)
@@ -99,21 +90,12 @@ BOOST_AUTO_TEST_CASE(addWorkSeq)
     works.push_back(work1);
     works.push_back(work2);
 
-    bool excepted = false;
-    try
-    {
-        queue->enqueueWorkSeq(works);
-    }
-    catch (const WorkExists& )
-    {
-        excepted = true;
-    }
+    queue->enqueueWorkSeq(works);
 
-    BOOST_CHECK(excepted == false);
     BOOST_CHECK(listener->addedNotice == true);
     BOOST_CHECK(listener->addedEmptyNotice == true);
     BOOST_CHECK(listener->emptyNotice == false);
-    BOOST_CHECK(queue->workCount() == 2);
+    BOOST_CHECK(queue->getSize() == 2);
 }
 
 BOOST_AUTO_TEST_CASE(appendWork)
@@ -126,78 +108,12 @@ BOOST_AUTO_TEST_CASE(appendWork)
     queue->enqueueWork(work1);
     listener->addedNotice = false;
 
-    bool excepted = false;
-    try
-    {
-        queue->enqueueWork(work2);
-    }
-    catch (const WorkExists& )
-    {
-        excepted = true;
-    }
+    queue->enqueueWork(work2);
 
-    BOOST_CHECK(excepted == false);
     BOOST_CHECK(listener->addedNotice == true);
     BOOST_CHECK(listener->addedEmptyNotice == false);
     BOOST_CHECK(listener->emptyNotice == false);
-    BOOST_CHECK(queue->workCount() == 2);
-}
-
-BOOST_AUTO_TEST_CASE(addExistentWork)
-{
-    TestListenerPtr listener(new TestListener);
-    QueuePtr queue(new WorkQueue(listener));
-    TaskPtr work(new Task);
-
-    queue->enqueueWork(work);
-
-    bool excepted = false;
-    try
-    {
-        queue->enqueueWork(work);
-    }
-    catch(const WorkExists& error)
-    {
-        excepted = true;
-        BOOST_CHECK(error.items.front() == work);
-    }
-
-    BOOST_CHECK(excepted == true);
-    BOOST_CHECK(queue->workCount() == 1);
-}
-
-BOOST_AUTO_TEST_CASE(addExistentWorkSeq)
-{
-    TestListenerPtr listener(new TestListener);
-    QueuePtr queue(new WorkQueue(listener));
-    TaskPtr work1(new Task);
-    TaskPtr work2(new Task);
-    TaskPtr work3(new Task);
-    WorkSeq works1;
-    WorkSeq works2;
-    works1.push_back(work1);
-    works1.push_back(work2);
-    works2.push_back(work3);
-    works2.push_back(work2);
-    
-    queue->enqueueWorkSeq(works1);
-
-    bool excepted = false;
-    try
-    {
-        queue->enqueueWorkSeq(works2);
-    }
-    catch (const WorkExists& error)
-    {
-        excepted = true;
-        BOOST_CHECK(error.items.front() == work2);
-    }
-
-    BOOST_CHECK(excepted == true);
-    BOOST_CHECK(listener->addedNotice == true);
-    BOOST_CHECK(listener->addedEmptyNotice == true);
-    BOOST_CHECK(listener->emptyNotice == false);
-    BOOST_CHECK(queue->workCount() == 2);
+    BOOST_CHECK(queue->getSize() == 2);
 }
 
 BOOST_AUTO_TEST_CASE(cancelWork)
@@ -220,7 +136,7 @@ BOOST_AUTO_TEST_CASE(cancelWork)
 
     BOOST_CHECK(excepted == false);
     BOOST_CHECK(listener->emptyNotice == true);
-    BOOST_CHECK(queue->workCount() == 0);
+    BOOST_CHECK(queue->getSize() == 0);
 }
 
 BOOST_AUTO_TEST_CASE(cancelNonExistent1)
@@ -243,7 +159,7 @@ BOOST_AUTO_TEST_CASE(cancelNonExistent1)
     BOOST_CHECK(listener->addedNotice == false);
     BOOST_CHECK(listener->addedEmptyNotice == false);
     BOOST_CHECK(listener->emptyNotice == false);
-    BOOST_CHECK(queue->workCount() == 0);
+    BOOST_CHECK(queue->getSize() == 0);
 }
 
 BOOST_AUTO_TEST_CASE(cancelNonExistent2)
@@ -266,7 +182,7 @@ BOOST_AUTO_TEST_CASE(cancelNonExistent2)
     }
 
     BOOST_CHECK(excepted == true);
-    BOOST_CHECK(queue->workCount() == 1);
+    BOOST_CHECK(queue->getSize() == 1);
 }
 
 BOOST_AUTO_TEST_CASE(workExecution)
@@ -281,7 +197,7 @@ BOOST_AUTO_TEST_CASE(workExecution)
     BOOST_CHECK(moreWork == false);
     BOOST_CHECK(work->taskExecuted == true);
     BOOST_CHECK(listener->emptyNotice == true);
-    BOOST_CHECK(queue->workCount() == 0);
+    BOOST_CHECK(queue->getSize() == 0);
 }
 
 BOOST_AUTO_TEST_CASE(executeNonExistent)
@@ -292,7 +208,7 @@ BOOST_AUTO_TEST_CASE(executeNonExistent)
     bool moreWork = queue->executeWork();
 
     BOOST_CHECK(moreWork == false);
-    BOOST_CHECK(queue->workCount() == 0);
+    BOOST_CHECK(queue->getSize() == 0);
     BOOST_CHECK(listener->emptyNotice == false);
 }
 
@@ -317,7 +233,7 @@ BOOST_AUTO_TEST_CASE(executionOrder1)
     BOOST_CHECK(moreWork == false);
     BOOST_CHECK(work2->taskExecuted == true);
     BOOST_CHECK(listener->emptyNotice == true);
-    BOOST_CHECK(queue->workCount() == 0);
+    BOOST_CHECK(queue->getSize() == 0);
 }
 
 BOOST_AUTO_TEST_CASE(executionOrder2)
@@ -365,7 +281,7 @@ BOOST_AUTO_TEST_CASE(executionOrder2)
     BOOST_CHECK(moreWork == false);
     BOOST_CHECK(work4->taskExecuted == true);
     BOOST_CHECK(listener->emptyNotice == true);
-    BOOST_CHECK(queue->workCount() == 0);
+    BOOST_CHECK(queue->getSize() == 0);
 }
 
 BOOST_AUTO_TEST_SUITE_END()

-----------------------------------------------------------------------


-- 
asterisk-scf/integration/ice-util-cpp.git



More information about the asterisk-scf-commits mailing list