summaryrefslogtreecommitdiffhomepage
path: root/logic
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-11-18 20:56:59 +0100
committerStanislaw Halik <sthalik@misaki.pl>2016-11-18 20:56:59 +0100
commit31ce79a7acd7d7667e20906e265d7451fa1c353f (patch)
treeba5f14155d49b5d36cd98364a1663110a757072c /logic
parentebe34fc7957752abdc6b86a288904dac339fe035 (diff)
logic/tracker: fix incorrect atomic bitmask usage
Diffstat (limited to 'logic')
-rw-r--r--logic/tracker.cpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/logic/tracker.cpp b/logic/tracker.cpp
index cfc62c84..61905837 100644
--- a/logic/tracker.cpp
+++ b/logic/tracker.cpp
@@ -449,25 +449,34 @@ void Tracker::get_raw_and_mapped_poses(double* mapped, double* raw) const
void bits::set(bits::flags flag_, bool val_)
{
- unsigned b_(b);
const unsigned flag = unsigned(flag_);
- const unsigned val = unsigned(!!val_);
- while (!b.compare_exchange_weak(b_,
+ const unsigned val = unsigned(val_);
+
+ 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))
- { /* empty */ }
+ break;
+ }
}
void bits::negate(bits::flags flag_)
{
- unsigned b_(b);
const unsigned flag = unsigned(flag_);
- while (!b.compare_exchange_weak(b_,
- (b_ & ~flag) | (flag & ~b_),
+
+ for (;;)
+ {
+ unsigned b_(b);
+
+ if (b.compare_exchange_weak(b_,
+ b_ ^ flag,
std::memory_order_seq_cst,
std::memory_order_seq_cst))
- { /* empty */ }
+ break;
+ }
}
bool bits::get(bits::flags flag)