Boost logo

Boost Users :

Subject: [Boost-users] [atomic] When to load/store
From: Michael Powell (mwpowellhtx_at_[hidden])
Date: 2013-05-22 11:04:39


Hello,

I have some thread synchronization to do, probably will end up using
some sort of internally synchronized cancelation or other state to
message between parent and child thread.

If the state uses boost::atomic<bool> _canceled, for instance, how do
I go about setting/getting the value? I am assuming that we do
something like this:

//To get the value.
return _canceled.load(boost::memory_order::memory_order_acq_rel);

//To set the value.
_canceled.store(canceled, boost::memory_order::memory_order_acq_rel);

Using acquire/release to get in, do what we need with the value, and
get out, type thing.

Also bearing in mind this is targeting ARM architecture (ARM5 I think).

Also, how complex a value can be protected? Are we talking primitive
types only? Basic data types like bool, int, float, that sort of
thing?

Thank you...

Regards,

Michael Powell


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