Skip to content

Files

Failed to load latest commit information.

Latest commit

 Cannot retrieve latest commit at this time.

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Atomic

Q: Why we need "atomic"?
A: When multiple threads write to the same variable, the final value of the variable may be false. Why does this problem exist?
You can find the answer in 26.4 of Operating Systems: Three Easy Pieces

std::atomic

Each instantiation and full specialization of the std::atomic template defines an atomic type.
std::atomic is neither copyable nor movable.
if you want to use atomic variable, you should specify the type you want your variable be(use template to implement generics).
You can find the example in atomic.cpp.