|
Boost : |
From: Lance.Diduck_at_[hidden]
Date: 2008-04-21 09:56:00
> i would be careful with that ... one would need to make sure, that the
monitor/semaphore implementation is
> lock-free itself ...
I assume that you are referring to the push operation, and not the pop.
The pop of course has to block somehow.
Waking up a thread is for all practical purposes platform/scheduler
specific, but there are ways to do this without blocking the signaler.
One way I solved this was to use a pipe, with O_NONBLOCK set. There is
an additional shared variable, that indicates that the queue is empty,
otherwise nothing has to get written. poll() with a timeout is used on
the pop side. (in my case I had to integrate with another middleware
package that used file descriptors, so there were few other choices).
Windows has events, which I believe are nonblocking already (and Windows
has one of the best queueing mechanisms around -- perhaps it is already
lock-free making boost.lockfree::queue a wrapper?). I'm not sure how I
would do this with pthreads.
In any case all of this is independent of the actual implementation of
the queue itself. It would just be nice to have a mechanism similar to
that already found in Java. Its lock-free queue has a monitor version.
-----Original Message-----
From: boost-bounces_at_[hidden]
[mailto:boost-bounces_at_[hidden]] On Behalf Of Tim Blechmann
Sent: Saturday, April 19, 2008 6:19 AM
To: boost_at_[hidden]
Subject: Re: [boost] Nonlocking data structures.
> Now, without knowing anything about how ctor, dtor, push and pop are
> implemented, what can be done? Adding allocator as a parameter just
> like a std::container;
beside using an stl-style allocator it might makes sense to use a
caching free-list ...
> perhaps
> making a version that includes a monitor (so that pop blocks rather
> than returns false) and so forth.
i would be careful with that ... one would need to make sure, that the
monitor/semaphore implementation is lock-free itself ...
cheers, tim
-- tim_at_[hidden] http://tim.klingt.org There's no such entity as "most people". These are generalities. All generalities are meaningless. You've got to pin it down to a specific person doing a specific thing at a specific time and space. William S. Burroughs _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost Visit our website at http://www.ubs.com This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mails are not encrypted and cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. This message is provided for informational purposes and should not be construed as a solicitation or offer to buy or sell any securities or related financial instruments.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk