On 19/05/2015 01:02, Sebastian Messerschmidt wrote:
Am 18.05.2015 um 13:51 schrieb Ran Shalit:
Hello,
I'm newbie of boost library.
I would like to ask if the lockless queue waits on empty queue ? (I actually need it to wait). You can easily wait yourself, and everyone would want to wait differently, so there is no point in putting into the queue's implementation. For instance you could give up your scheduler time-slice, or you might want to spin-lock
while(!queue.pop(my_data)) { boost::this_thread::yield(); //give up time slice }
You can also do a "real" wait until something has been pushed (which can be important as yield() does not let lower-priority threads run), but currently doing that requires using either Win32 events or using condition variables -- but the latter requires adding a mutex on both ends, which may defeat the point of using a lock-free queue in the first place.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users It would be an interesting exercise to integrate lock-less queue with
On 19.05.2015 03:28, Gavin Lambert wrote: libdispatch or similar open source event library. But then again, with task queues like those of libdispatch around you may be able avoid multi-threading issues in first place. Leon