aboutsummaryrefslogtreecommitdiff
path: root/src/threading.cpp
diff options
context:
space:
mode:
authorLucas Perlind <lucas@jangafx.com>2025-09-24 12:42:20 +1000
committerjanga-perlind <lucas@jangafx.com>2025-09-24 15:54:58 +1000
commit15b4b9277a58e0c10e4da698701fbf806d0c45b9 (patch)
treeeb922461d61820e7b0229cb331c2b10cdee88fde /src/threading.cpp
parenteca2758d8b4768ab370d9539c1098235f8a08076 (diff)
spin in recursive mutex lock; use compare exchange for broadcast
Diffstat (limited to 'src/threading.cpp')
-rw-r--r--src/threading.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/threading.cpp b/src/threading.cpp
index a35176ce6..84f09912d 100644
--- a/src/threading.cpp
+++ b/src/threading.cpp
@@ -195,7 +195,13 @@ gb_internal void mutex_lock(RecursiveMutex *m) {
// inside the lock
return;
}
- futex_wait(&m->owner, prev_owner);
+
+ // NOTE(lucas): we are doing spin lock since futex signal is expensive on OSX. The recursive locks are
+ // very short lived so we don't hit this mega often and I see no perform regression on windows (with
+ // a performance uplift on OSX).
+
+ //futex_wait(&m->owner, prev_owner);
+ yield_thread();
}
}
gb_internal bool mutex_try_lock(RecursiveMutex *m) {
@@ -216,7 +222,9 @@ gb_internal void mutex_unlock(RecursiveMutex *m) {
return;
}
m->owner.exchange(0, std::memory_order_release);
- futex_signal(&m->owner);
+ // NOTE(lucas): see comment about spin lock in mutex_lock above
+
+ // futex_signal(&m->owner);
// outside the lock
}