Code: Select all
void ThreadManager::InThread()
{
boost::posix_time::milliseconds workTime(5);
while (running)
{
boost::this_thread::sleep(workTime);
if (running == false) break;
boost::shared_ptr<map<string, boost::shared_ptr<void> > > item;
while (true)
{
inQueueLocker.lock();
if(inThreadQueue->size() <= 0) {
inQueueLocker.unlock();
break;
}
item = inThreadQueue->front();
inThreadQueue->pop_front();
inQueueLocker.unlock();
ProcessItem(item);
item->clear();
}
}
}
Code: Select all
void ThreadManager::OutThread()
{
boost::posix_time::milliseconds workTime(5);
while (running)
{
boost::this_thread::sleep(workTime);
if (running == false) break;
boost::shared_ptr<map<string, boost::shared_ptr<void> > > item;
while (true)
{
outQueueLocker.lock();
if (outThreadQueue->size() <= 0) {
outQueueLocker.unlock();
break;
}
item = outThreadQueue->front();
outThreadQueue->pop_front();
outQueueLocker.unlock();
ProcessOutItem(item);
item->clear();
}
}
}
Notice how the lock is shortened to only lock popping from the queue and not to also lock the actual processing of the input or output item.
Please take a look at this for us in more detail and provide us a more official patch for this issue. Thanks!