Replace condition+mutex with futex

This commit is contained in:
gingerBill
2023-01-02 00:26:17 +00:00
parent d16ddf7926
commit 3c90a05957
3 changed files with 39 additions and 40 deletions

View File

@@ -393,7 +393,7 @@ gb_internal void thread_init(ThreadPool *pool, Thread *t, isize idx) {
#endif
t->capacity = 1 << 14; // must be a power of 2
t->queue = (WorkerTask *)calloc(sizeof(WorkerTask), t->capacity);
t->queue = gb_alloc_array(heap_allocator(), WorkerTask, t->capacity);
t->head_and_tail = 0;
t->pool = pool;
t->idx = idx;
@@ -429,6 +429,8 @@ gb_internal void thread_join_and_destroy(Thread *t) {
pthread_join(t->posix_handle, NULL);
t->posix_handle = 0;
#endif
gb_free(heap_allocator(), t->queue);
}
gb_internal void thread_set_name(Thread *t, char const *name) {