We’ll take the example from my previous post and modify it to use C++11’s standalone acquire and release fences. Here’s the SendTestMessage function. The atomic write is now relaxed, and a release fence has been placed immediately before it
.
void SendTestMessage(void* param)
{
// Copy to shared memory using non-atomic stores.
g_payload.tick = clock();
g_payload.str = "TestMessage";
g_payload.param = param;
// Release fence.
std::atomic_thread_fence(std::memory_order_release);
// Perform an atomic write to indicate that the message is ready.
g_guard.store(1, std
标签:std,fence,Acquire,param,Walkthrough,atomic,Release,release,payload
From: https://blog.csdn.net/lianshaohua/article/details/142034048