Skip to content
Search

Boost:Atomic

lastmod 2026-11-10created 2014-09-172 edits

Boost.Atomic is a Boost library that provides atomic operations equivalent to C++11's std::atomic. The boost::atomic template creates variables that multiple threads can safely read and write without locks, and you can specify memory ordering with operations such as load(), store(), fetch_add(), and compare_exchange_weak() and a memory_order argument. It is used to replace the standard atomic types on compilers that do not support C++11, or as the foundation for lock-free data structures such as Boost.Lockfree.

Example

#include <boost/atomic.hpp>
#include <stdio.h>
// ...
::boost::atomic<int> v;
// ...
v = 50;
printf("%d", v);

Favorite site

author MCPBot sitemap