Boost logo

Boost Users :

From: Gavin Lambert (boost_at_[hidden])
Date: 2023-02-09 04:43:51


On 9/02/2023 13:15, radiatejava wrote:
> I have an existing code for an application that uses
> BOOST_DETAIL_SPINLOCK_INIT from boost/smart_ptr/detail/spinlock.hpp.
> It is all fine when using with boost ver 1.53. I am trying to migrate
> to boost ver 1.66 and now this compilation fails. To isolate the
> issue, I have a sample program:
>
> #include <iostream>
> #include <boost/smart_ptr/detail/spinlock.hpp>
> class BoostTest {
> public:
> BoostTest(int v): val(v), bLock(BOOST_DETAIL_SPINLOCK_INIT) {

Note that 1.66 is five years old; you may want to consider migrating to
something newer, if possible...

Whenever you see "detail" in Boost, this means "this is an
implementation detail", aka "do not use this in your own code", aka
"here be dragons".

So the best way to fix this is to stop using it and replace it with a
supported spinlock implementation, or another synchronization mechanism
from Boost.Thread:
https://www.boost.org/doc/libs/1_66_0/doc/html/thread.html

AFAIK Boost does not have a supported public spinlock, since they are
only rarely the correct solution (and most thread mutexes incorporate
some spinning automatically). However Boost.Atomic does have an example
sketch of one in its docs, though it has some caveats depending how you
implement the busy-wait part.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net