Boost logo

Boost :

Subject: Re: [boost] [thread] Can Boost.Thread use Boost.Atomic without falling on a compatibility issue?
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2013-01-13 13:56:36

On Sun, Jan 13, 2013 at 10:43 PM, Vicente J. Botet Escriba
<vicente.botet_at_[hidden]> wrote:
> I would like to have an alternative for these platforms to avoid making
> Boost.Thread fail just because Boost.Atomic is not supported.

It won't fail, it will use the spinlock pool. When the spinlock cannot
be implemented with atomic ops (i.e. on a not supported platform) the
spinlock is implemented as boost::mutex from Boost.Thread.

I realize this would make the implementation suboptimal in case of
call_once. In that case we could fallback to a special implementation
that only uses pthread API. That would require to always lock the
mutex, even when the initialization is already done.

PS: It might be worthwhile to actually try to use the spinlocks from
pthread API in Boost.Atomic.

Boost list run by bdawes at, gregod at, cpdaniel at, john at