diff options
| author | gingerBill <bill@gingerbill.org> | 2024-07-15 01:05:29 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2024-07-15 01:05:29 +0100 |
| commit | a8f84c87ae7b4d30cf197f54cbc05da024a17d24 (patch) | |
| tree | 38c86b479278565e9bedc31e240c802c168c570c /src/threading.cpp | |
| parent | c64702ae5ad57240743fc425bb5029fb9c1cc02e (diff) | |
Add the permanent and temporary arenas directly on the `Thread`
Diffstat (limited to 'src/threading.cpp')
| -rw-r--r-- | src/threading.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/threading.cpp b/src/threading.cpp index ff0fdfcde..c622ac87e 100644 --- a/src/threading.cpp +++ b/src/threading.cpp @@ -70,6 +70,9 @@ struct Thread { struct TaskQueue queue; struct ThreadPool *pool; + + struct Arena *permanent_arena; + struct Arena *temporary_arena; }; typedef std::atomic<i32> Futex; @@ -560,18 +563,20 @@ gb_internal void *internal_thread_proc(void *arg) { } #endif -TaskRingBuffer *task_ring_init(isize size) { +gb_internal TaskRingBuffer *task_ring_init(isize size) { TaskRingBuffer *ring = gb_alloc_item(heap_allocator(), TaskRingBuffer); ring->size = size; ring->buffer = gb_alloc_array(heap_allocator(), WorkerTask, ring->size); return ring; } -void thread_queue_destroy(TaskQueue *q) { +gb_internal void thread_queue_destroy(TaskQueue *q) { gb_free(heap_allocator(), (*q->ring).buffer); gb_free(heap_allocator(), q->ring); } +gb_internal void thread_init_arenas(Thread *t); + gb_internal void thread_init(ThreadPool *pool, Thread *t, isize idx) { gb_zero_item(t); #if defined(GB_SYSTEM_WINDOWS) @@ -584,6 +589,8 @@ gb_internal void thread_init(ThreadPool *pool, Thread *t, isize idx) { t->queue.ring = task_ring_init(1 << 14); t->pool = pool; t->idx = idx; + + thread_init_arenas(t); } gb_internal void thread_init_and_start(ThreadPool *pool, Thread *t, isize idx) { |