O'Reilly logo

C++ Reactive Programming by Peter Abraham, Praseed Pai

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

std::atomic<bool>

std::atomic<bool> is a full-featured atomic Boolean type compared to std::atomic_flag. But neither copy-construction nor assignment is possible with this type. The value of an std::atomic<bool> object can initially be either true or false. The objects of this type can be constructed or assigned values from a non-atomic bool:

std::atomic<bool> flg(true);flg = false;

One thing needs to be noted about the assignment operator of atomic types, which is that the operator returns the value of non-atomic types rather than the conventional scheme of returning references. If a reference is returned instead of a value, it would create a situation where the result of assignment gets the result of a modification by another thread, that ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required