atomic_flag_test_and_set
atomic_flag_test_and_set_explicit
atomic_flag_clear
atomic_flag_clear_explicit
Here is an example:
#include <atomic>
#include <iostream>
using namespace std;
int main()
{
atomic_flag memoryOrder = ATOMIC_FLAG_INIT;
bool isMemoryOrderRelaxed=memoryOrder.test_and_set(memory_order_relaxed);
bool isMemoryOrderConsume=memoryOrder.test_and_set(memory_order_consume);
bool isMemoryOrderAcquire=memoryOrder.test_and_set(memory_order_acquire);
bool isMemoryOrderRelease=memoryOrder.test_and_set(memory_order_release);
bool isMemoryOrderAcqRel =memoryOrder.test_and_set(memory_order_acq_rel);
bool isMemoryOrderSeqCst =memoryOrder.test_and_set(memory_order_seq_cst);
cout << isMemoryOrderRelaxed << " ";
cout << isMemoryOrderConsume << " ";
cout << isMemoryOrderAcquire << " ";
cout << isMemoryOrderRelease << " ";
cout << isMemoryOrderAcqRel << " ";
cout << isMemoryOrderSeqCst << " ";
cout << endl;
return 0;
}
// Output: 0 1 1 1 1 1
Reference: http://en.cppreference.com/w/cpp/atomichttp://en.cppreference.com/w/cpp/atomic/memory_order
No comments:
Post a Comment