Boost logo

Threads-Devel :

Subject: Re: [Threads-devel] boost.thread low-level primitives?
From: Tim Blechmann (tim_at_[hidden])
Date: 2009-10-29 08:41:33


>> i am regularly using primitives like spinlocks or semaphores for
>> low-level synchronization issues.
>> i am curious, why these primitives don't exist? would there be some
>> interest in adding such classes to boost.thread?
>
> A long time ago, before I got involved with Boost.thread, it was decided
> that semaphores were too low-level, and hard to program with. I don't
> know whether spinlocks were also considered.
>
> I'm happy to revisit these decisions if there's a consensus to do so.

semaphores may be low-level, but from my experience more efficient than
(boost) condition variables.
http://tim.klingt.org/git?p=nova-tt.git;a=blob;f=nova-tt/semaphore.hpp

also, it would be great to see (reader/writer) spinlocks:
http://tim.klingt.org/git?p=nova-tt.git;a=blob;f=nova-tt/spin_lock.hpp
http://tim.klingt.org/git?p=nova-tt.git;a=blob;f=nova-tt/rw_spinlock.hpp

btw, i also found that a wrapper for pthread_rwlock_t more efficient,
than boost::shared_mutex, not sure, if they match the guaranties of
boost::shared_mutex, though:
http://tim.klingt.org/git?p=nova-tt.git;a=blob;f=nova-tt/rw_mutex.hpp

tim

-- 
tim_at_[hidden]
http://tim.klingt.org
After one look at this planet any visitor from outer space would say
"I want to see the manager."
  William S. Burroughs



Threads-Devel list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk