diff options
| author | gingerBill <bill@gingerbill.org> | 2021-07-27 23:14:01 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2021-07-27 23:14:01 +0100 |
| commit | a5d6fda4338641a64d07b353129e5731a6517941 (patch) | |
| tree | 0cce749ad561e7a27b3c5eb0d6443f3d58a6df34 /src/queue.cpp | |
| parent | 4bc3796f9b9e8ea00ff0da89f6e983345fb2fd7e (diff) | |
Define which mutexes are blocking and recursive explicitly
Diffstat (limited to 'src/queue.cpp')
| -rw-r--r-- | src/queue.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/queue.cpp b/src/queue.cpp index 4d7c0f052..db92ec72a 100644 --- a/src/queue.cpp +++ b/src/queue.cpp @@ -18,7 +18,7 @@ struct MPMCQueue { CacheLinePad pad0; isize mask; Array<MPMCQueueNode<T>> buffer; - gbMutex mutex; + BlockingMutex mutex; std::atomic<isize> count; CacheLinePad pad1; @@ -37,7 +37,7 @@ void mpmc_init(MPMCQueue<T> *q, gbAllocator a, isize size) { size = next_pow2_isize(size); GB_ASSERT(gb_is_power_of_two(size)); - gb_mutex_init(&q->mutex); + mutex_init(&q->mutex); q->mask = size-1; array_init(&q->buffer, a, size); @@ -57,7 +57,7 @@ void mpmc_init(MPMCQueue<T> *q, gbAllocator a, isize size) { template <typename T> void mpmc_destroy(MPMCQueue<T> *q) { - gb_mutex_destroy(&q->mutex); + mutex_destroy(&q->mutex); gb_free(q->buffer.allocator, q->buffer.data); } @@ -83,13 +83,13 @@ isize mpmc_enqueue(MPMCQueue<T> *q, T const &data) { return q->count.fetch_add(1, std::memory_order_release); } } else if (diff < 0) { - gb_mutex_lock(&q->mutex); + mutex_lock(&q->mutex); isize old_size = q->buffer.count; isize new_size = old_size*2; array_resize(&q->buffer, new_size); if (q->buffer.data == nullptr) { GB_PANIC("Unable to resize enqueue: %td -> %td", old_size, new_size); - gb_mutex_unlock(&q->mutex); + mutex_unlock(&q->mutex); return -1; } // NOTE(bill): pretend it's not atomic for performance @@ -98,7 +98,7 @@ isize mpmc_enqueue(MPMCQueue<T> *q, T const &data) { raw_data[i].idx = i; } q->mask = new_size-1; - gb_mutex_unlock(&q->mutex); + mutex_unlock(&q->mutex); } else { head_idx = q->head_idx.load(std::memory_order_relaxed); } |