diff options
| author | Lucas Perlind <lucas@jangafx.com> | 2025-09-24 12:40:01 +1000 |
|---|---|---|
| committer | Lucas Perlind <lucas@jangafx.com> | 2025-09-24 12:40:01 +1000 |
| commit | eca2758d8b4768ab370d9539c1098235f8a08076 (patch) | |
| tree | 9d260250fb69f9ec53e6b4683ffc2ec861f85800 | |
| parent | e9d20a9b4a069815f76a23ce5f429862b155b2d6 (diff) | |
Revert "Reimplement `RwMutex` on non-windows systems"
This reverts commit e9d20a9b4a069815f76a23ce5f429862b155b2d6.
| -rw-r--r-- | src/threading.cpp | 32 |
1 files changed, 8 insertions, 24 deletions
diff --git a/src/threading.cpp b/src/threading.cpp index b1a0af2e4..a35176ce6 100644 --- a/src/threading.cpp +++ b/src/threading.cpp @@ -423,44 +423,28 @@ gb_internal void semaphore_wait(Semaphore *s) { } struct RwMutex { - BlockingMutex lock; - Condition cond; - int32_t readers; + // TODO(bill): make this a proper RW mutex + BlockingMutex mutex; }; gb_internal void rw_mutex_lock(RwMutex *m) { - mutex_lock(&m->lock); - while (m->readers != 0) { - condition_wait(&m->cond, &m->lock); - } + mutex_lock(&m->mutex); } gb_internal bool rw_mutex_try_lock(RwMutex *m) { - // TODO(bill): rw_mutex_try_lock - rw_mutex_lock(m); - return true; + return mutex_try_lock(&m->mutex); } gb_internal void rw_mutex_unlock(RwMutex *m) { - condition_signal(&m->cond); - mutex_unlock(&m->lock); + mutex_unlock(&m->mutex); } gb_internal void rw_mutex_shared_lock(RwMutex *m) { - mutex_lock(&m->lock); - m->readers += 1; - mutex_unlock(&m->lock); + mutex_lock(&m->mutex); } gb_internal bool rw_mutex_try_shared_lock(RwMutex *m) { - // TODO(bill): rw_mutex_try_shared_lock - rw_mutex_shared_lock(m); - return true; + return mutex_try_lock(&m->mutex); } gb_internal void rw_mutex_shared_unlock(RwMutex *m) { - mutex_lock(&m->lock); - m->readers -= 1; - if (m->readers == 0) { - condition_signal(&m->cond); - } - mutex_unlock(&m->lock); + mutex_unlock(&m->mutex); } #endif |