Subject: Re: [boost] [thread] shared_spinlock_t idea or faster shared_lock
From: Giovanni Piero Deretta (gpderetta_at_[hidden])
Date: 2014-05-02 05:26:15
On Fri, May 2, 2014 at 6:37 AM, Antony Polukhin <antoshkka_at_[hidden]> wrote:
> This is just a refining of idea that was once implemented and worked well.
> The idea was to make shared spin lock. Here is some pseudo-code:
> When all the *_wait() and writer_*() functions do nothing we get a shared
> Now if we add helper mutex and make all the *_wait() functions to lock and
> unlock mutex; writer_start() - lock the mutex; writer finished() - unlock
> the mutex... we get a simplified shared_mutex that is faster (in theory)
> than current implementation.
> Is there an interest in such shared_spinlock_t? Any comments, suggestions?
Not sure, you generally want to use a spinlock when you expect
contention to be very low. If you expect contention to be high enough
that a r/w lock could be a win, you probably do not want to spin
There is also the geneal issue of naive r/w locks with readers
contending for an exclusive cacheline.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk