aboutsummaryrefslogtreecommitdiff
path: root/include/salticidae/queue.h
diff options
context:
space:
mode:
authorDeterminant <ted.sybil@gmail.com>2019-03-27 11:05:12 -0400
committerDeterminant <ted.sybil@gmail.com>2019-03-27 11:05:12 -0400
commitc91fdee8e845a2eccbc680c2d88748b2ac95a407 (patch)
tree4a03e9c2d5ea752517d6811b5ec193268a39e361 /include/salticidae/queue.h
parenta4015bde81371a8b998361ccfb56d5fd714e3ec6 (diff)
...
Diffstat (limited to 'include/salticidae/queue.h')
-rw-r--r--include/salticidae/queue.h10
1 files changed, 5 insertions, 5 deletions
diff --git a/include/salticidae/queue.h b/include/salticidae/queue.h
index 1732238..598303c 100644
--- a/include/salticidae/queue.h
+++ b/include/salticidae/queue.h
@@ -148,7 +148,7 @@ class MPMCQueue {
bool try_dequeue(T &e) {
for (;;)
{
- auto h = head.load(std::memory_order_acquire);
+ auto h = head.load(std::memory_order_relaxed);
auto t = h->refcnt.load(std::memory_order_relaxed);
if (!t) continue;
if (h->refcnt.compare_exchange_weak(t, t + 1, std::memory_order_consume))
@@ -178,13 +178,13 @@ template<typename T>
struct MPSCQueue: public MPMCQueue<T> {
using MPMCQueue<T>::MPMCQueue;
bool try_dequeue(T &e) {
- auto h = this->head.load(std::memory_order_acquire);
+ auto h = this->head.load(std::memory_order_relaxed);
auto nh = h->next.load(std::memory_order_relaxed);
- if (nh == nullptr)
- return false;
std::atomic_thread_fence(std::memory_order_acquire);
+ if (nh == nullptr) return false;
e = std::move(nh->elem);
- this->head.store(nh, std::memory_order_release);
+ std::atomic_thread_fence(std::memory_order_release);
+ this->head.store(nh, std::memory_order_relaxed);
this->blks.push(h);
return true;
}