|
Boost Users : |
Subject: [Boost-users] safe check if lockfree::queue is empty
From: niXman (i.nixman_at_[hidden])
Date: 2013-04-02 06:45:24
Hi,
I read the docs about lockfree::queue::empty() and understang what this way
is not safe in multithreaded program.
The question is, how can I verify that the queue is empty?
Will it be correct the following code?
bool empty() {
T *tmp = 0;
if ( queue.pop(tmp) ) {
queue.push(tmp);
return false;
}
return true;
}
Thanks.
-- Regards, niXman ___________________________________________________ Dual-target(32 & 64-bit) MinGW compilers for 32 and 64-bit Windows: http://sourceforge.net/projects/mingwbuilds/ ___________________________________________________ Another online IDE: http://liveworkspace.org/
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net