aboutsummaryrefslogtreecommitdiff
path: root/src/threading.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2023-01-02 17:18:59 +0000
committergingerBill <bill@gingerbill.org>2023-01-02 17:18:59 +0000
commit9737b65d9c2c4c09fd1a0ec1daa3dd7dcdeb7dc5 (patch)
tree9ddbfe0c65f703dab18af28537df8d92740427a6 /src/threading.cpp
parentad52003077d579600d810b1337ca4d7904a1fc9b (diff)
Explicitly call `store` for futex
Diffstat (limited to 'src/threading.cpp')
-rw-r--r--src/threading.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/threading.cpp b/src/threading.cpp
index c5db5d1b4..169b9ff43 100644
--- a/src/threading.cpp
+++ b/src/threading.cpp
@@ -117,7 +117,8 @@ struct RecursiveMutex {
};
gb_internal void mutex_lock(RecursiveMutex *m) {
- Futex tid = cast(i32)thread_current_id();
+ Futex tid;
+ tid.store(cast(i32)thread_current_id());
for (;;) {
i32 prev_owner = 0;
m->owner.compare_exchange_strong(prev_owner, tid, std::memory_order_acquire, std::memory_order_acquire);
@@ -130,7 +131,8 @@ gb_internal void mutex_lock(RecursiveMutex *m) {
}
}
gb_internal bool mutex_try_lock(RecursiveMutex *m) {
- Futex tid = cast(i32)thread_current_id();
+ Futex tid;
+ tid.store(cast(i32)thread_current_id());
i32 prev_owner = 0;
m->owner.compare_exchange_strong(prev_owner, tid, std::memory_order_acquire, std::memory_order_acquire);
if (prev_owner == 0 || prev_owner == tid) {