Explorar o código

Explicitly call `store` for futex

gingerBill %!s(int64=2) %!d(string=hai) anos
pai
achega
9737b65d9c
Modificáronse 1 ficheiros con 4 adicións e 2 borrados
  1. 4 2
      src/threading.cpp

+ 4 - 2
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) {