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();
point->data=i;
queue.enqueueNotification(new WorkNotification(*point));
}
// wait until queue is empty and all threads are
// waiting for new work.
while (!queue.empty())
{Thread::sleep(200);
}
Thread::sleep(500);
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.





