Unable to compile when using BOOST_DETAIL_SPINLOCK_INIT
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
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
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.
participants (2)
-
Gavin Lambert
-
radiatejava