Add-Ons & Services

NotificationQueue: small Suggest

General discussion regarding the development of POCO for contributors.
Posts: 2
Joined: 26 Apr 2010, 14:23

NotificationQueue: small Suggest

Postby CarloMaker » 01 Sep 2010, 20:52

Just a word for to say "thank Poco".
I m using it for multi thread part on my project .. i m working around Notification Queue.
like sample i see in main:

Code: Select all

        NotificationQueue queue;
   std::cout << "USED " << ThreadPool::defaultPool().used() << std::endl;
   // distribute some work
   for (int i = 0; i < 50; ++i)
      TestPointer * point=new TestPointer();
      queue.enqueueNotification(new WorkNotification(*point));
   // wait until queue is empty and all threads are
   // waiting for new work.
   while (!queue.empty())


In code we need a Sleep 200 to complete last operation thread because the queue is empty but some thread needs more time to complete its work,
now, Sleep is very bad for my application(it run at 300-400 Hz).
So i resolved adding a new attribute in NQ's code:

int NotificationQueue::getIdlesThreads() const
FastMutex::ScopedLock lock(_mutex);
return _waitQueue.size();

So, i know : if getIdleThreads() == nWorkerThread im sure that all thread have finished.

Sry for my english... i hope to be clear.:)

Posts: 15
Joined: 13 Aug 2010, 15:28

Re: NotificationQueue: small Suggest

Postby huailongs » 02 Sep 2010, 16:27

i think it's not rigorous.

if getIdleThreads() == nWorkerThread im sure that all thread have finished.
then if getIdleThreads() == nWorkerThread ,u should sleep and wait again?

Return to “Contributors”

Who is online

Users browsing this forum: No registered users and 1 guest