Documentation Home >> Headers >> <atomic> Header >> std::atomic_thread_fence function

The std::atomic_thread_fence() function inserts a "memory barrier" or "fence" in the code to force memory ordering constaints between operations.

std::atomic_thread_fence(std::memory_order order);

Effects:

Insert a fence with the required memory ordering constraints.

A fence with an order of std::memory_order_release, std::memory_order_acq_rel or std::memory_order_seq_cst synchronizes-with an acquire operation on the some memory location if that acquire operation reads a value stored by an atomic operation following the fence on the same thread as the fence.

A release operation synchronizes-with a fence with an order of std::memory_order_acquire, std::memory_order_acq_rel or std::memory_order_seq_cst if that release operation stores a value which is read by an atomic operation prior to the fence on the same thread as the fence.

Throws:

Nothing.

Header

#include <atomic>

See Also