From 723f351a6d36193cb36c74c40b40befa3c4302f1 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sun, 1 Sep 2019 23:13:29 +0100 Subject: [PATCH] Remove custom allocator for thread pool --- src/thread_pool.cpp | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/src/thread_pool.cpp b/src/thread_pool.cpp index 67e698e5d..32fe3b82f 100644 --- a/src/thread_pool.cpp +++ b/src/thread_pool.cpp @@ -19,23 +19,10 @@ struct ThreadPool { Array tasks; Array threads; - gbAllocator original_allocator; - char worker_prefix[10]; i32 worker_prefix_len; }; - -GB_ALLOCATOR_PROC(thread_pool_allocator_proc) { - ThreadPool *pool = cast(ThreadPool *)allocator_data; - return pool->original_allocator.proc(pool->original_allocator.data, type, size, 256, old_memory, old_size, flags); -} - -gbAllocator thread_pool_allocator(ThreadPool *pool) { - gbAllocator a = {thread_pool_allocator_proc, pool}; - return a; -} - void thread_pool_init(ThreadPool *pool, gbAllocator const &a, isize thread_count, char const *worker_prefix = nullptr); void thread_pool_destroy(ThreadPool *pool); void thread_pool_start(ThreadPool *pool); @@ -46,10 +33,8 @@ void thread_pool_kick_and_wait(ThreadPool *pool); GB_THREAD_PROC(worker_thread_internal); void thread_pool_init(ThreadPool *pool, gbAllocator const &a, isize thread_count, char const *worker_prefix) { - pool->original_allocator = a; - gbAllocator tpa = thread_pool_allocator(pool); - pool->tasks = array_make(tpa, 0, 1024); - pool->threads = array_make(tpa, thread_count); + pool->tasks = array_make(a, 0, 1024); + pool->threads = array_make(a, thread_count); gb_mutex_init(&pool->task_mutex); gb_mutex_init(&pool->mutex); gb_semaphore_init(&pool->semaphore);