diff options
Diffstat (limited to 'source/blender/blenlib/BLI_threads.h')
-rw-r--r-- | source/blender/blenlib/BLI_threads.h | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/source/blender/blenlib/BLI_threads.h b/source/blender/blenlib/BLI_threads.h index 38ad0827246..7a3ee1dd0f4 100644 --- a/source/blender/blenlib/BLI_threads.h +++ b/source/blender/blenlib/BLI_threads.h @@ -45,6 +45,7 @@ extern "C" { #define BLENDER_MAX_THREADS 64 struct ListBase; +struct TaskScheduler; /* Threading API */ @@ -52,6 +53,8 @@ struct ListBase; void BLI_threadapi_init(void); void BLI_threadapi_exit(void); +struct TaskScheduler *BLI_task_scheduler_get(void); + void BLI_init_threads(struct ListBase *threadbase, void *(*do_thread)(void *), int tot); int BLI_available_threads(struct ListBase *threadbase); int BLI_available_thread_index(struct ListBase *threadbase); @@ -101,6 +104,7 @@ ThreadMutex *BLI_mutex_alloc(void); void BLI_mutex_free(ThreadMutex *mutex); void BLI_mutex_lock(ThreadMutex *mutex); +bool BLI_mutex_trylock(ThreadMutex *mutex); void BLI_mutex_unlock(ThreadMutex *mutex); /* Spin Lock */ @@ -144,27 +148,15 @@ void BLI_ticket_mutex_free(TicketMutex *ticket); void BLI_ticket_mutex_lock(TicketMutex *ticket); void BLI_ticket_mutex_unlock(TicketMutex *ticket); -/* ThreadedWorker - * - * A simple tool for dispatching work to a limited number of threads - * in a transparent fashion from the caller's perspective. */ - -struct ThreadedWorker; - -/* Create a new worker supporting tot parallel threads. - * When new work in inserted and all threads are busy, sleep(sleep_time) before checking again - */ -struct ThreadedWorker *BLI_create_worker(void *(*do_thread)(void *), int tot, int sleep_time); - -/* join all working threads */ -void BLI_end_worker(struct ThreadedWorker *worker); - -/* also ends all working threads */ -void BLI_destroy_worker(struct ThreadedWorker *worker); +/* Condition */ + +typedef pthread_cond_t ThreadCondition; -/* Spawns a new work thread if possible, sleeps until one is available otherwise - * NOTE: inserting work is NOT thread safe, so make sure it is only done from one thread */ -void BLI_insert_work(struct ThreadedWorker *worker, void *param); +void BLI_condition_init(ThreadCondition *cond); +void BLI_condition_wait(ThreadCondition *cond, ThreadMutex *mutex); +void BLI_condition_notify_one(ThreadCondition *cond); +void BLI_condition_notify_all(ThreadCondition *cond); +void BLI_condition_end(ThreadCondition *cond); /* ThreadWorkQueue * |