summaryrefslogtreecommitdiffhomepage
path: root/logic
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2018-06-05 08:37:52 +0200
committerStanislaw Halik <sthalik@misaki.pl>2018-06-13 07:02:53 +0200
commit63e1bb6605d78af73e52cc2ac38b46bd8d15c5f3 (patch)
tree8a6a1d9eded505f719925784f84a633c91024371 /logic
parentf128b1de42cf8b2d9b50f57561a205073b9e250d (diff)
logic/pipeline: fix atomic ops
No functional changes. Don't perform any atomic reads before compare-and-swap. The value read by CAS needs to go outside the loop. That's how CAS works.
Diffstat (limited to 'logic')
-rw-r--r--logic/pipeline.cpp15
1 files changed, 4 insertions, 11 deletions
diff --git a/logic/pipeline.cpp b/logic/pipeline.cpp
index 4756db3e..c36d1781 100644
--- a/logic/pipeline.cpp
+++ b/logic/pipeline.cpp
@@ -642,14 +642,11 @@ void bits::set(flags flag_, bool val_)
{
const unsigned flag = unsigned(flag_);
const unsigned val = unsigned(val_);
+ unsigned b_ = 0;
for (;;)
{
- unsigned b_(b);
- if (b.compare_exchange_weak(b_,
- unsigned((b_ & ~flag) | (flag * val)),
- std::memory_order_seq_cst,
- std::memory_order_seq_cst))
+ if (b.compare_exchange_strong(b_, unsigned((b_ & ~flag) | (flag * val))))
break;
}
}
@@ -657,15 +654,11 @@ void bits::set(flags flag_, bool val_)
void bits::negate(flags flag_)
{
const unsigned flag = unsigned(flag_);
+ unsigned b_ = 0;
for (;;)
{
- unsigned b_(b);
-
- if (b.compare_exchange_weak(b_,
- b_ ^ flag,
- std::memory_order_seq_cst,
- std::memory_order_seq_cst))
+ if (b.compare_exchange_strong(b_, b_ ^ flag))
break;
}
}