diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-02-15 17:17:43 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-02-15 17:17:43 +0300 |
commit | ca5fdd857b7864b0336aca655f2c04d00090c0f9 (patch) | |
tree | 5e19a8ec6a5c08ba9d6e8cf1f98cd7d9980a5f23 /source/blender/blenlib | |
parent | df1c88b652e6977491b7f2b019c326518ccdc320 (diff) | |
parent | 2aef87bfae4a6a91f626780767aab68b7791c9d4 (diff) |
Merge branch 'master' into blender2.8
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_threads.h | 22 | ||||
-rw-r--r-- | source/blender/blenlib/intern/task.c | 4 | ||||
-rw-r--r-- | source/blender/blenlib/intern/threads.c | 30 |
3 files changed, 28 insertions, 28 deletions
diff --git a/source/blender/blenlib/BLI_threads.h b/source/blender/blenlib/BLI_threads.h index 84e25daa348..66eb5cfd22b 100644 --- a/source/blender/blenlib/BLI_threads.h +++ b/source/blender/blenlib/BLI_threads.h @@ -55,19 +55,19 @@ 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); +void BLI_threadpool_init(struct ListBase *threadbase, void *(*do_thread)(void *), int tot); int BLI_available_threads(struct ListBase *threadbase); -int BLI_available_thread_index(struct ListBase *threadbase); -void BLI_insert_thread(struct ListBase *threadbase, void *callerdata); -void BLI_remove_thread(struct ListBase *threadbase, void *callerdata); -void BLI_remove_thread_index(struct ListBase *threadbase, int index); -void BLI_remove_threads(struct ListBase *threadbase); -void BLI_end_threads(struct ListBase *threadbase); +int BLI_threadpool_available_thread_index(struct ListBase *threadbase); +void BLI_threadpool_insert(struct ListBase *threadbase, void *callerdata); +void BLI_threadpool_remove(struct ListBase *threadbase, void *callerdata); +void BLI_threadpool_remove_index(struct ListBase *threadbase, int index); +void BLI_threadpool_clear(struct ListBase *threadbase); +void BLI_threadpool_end(struct ListBase *threadbase); int BLI_thread_is_main(void); -void BLI_begin_threaded_malloc(void); -void BLI_end_threaded_malloc(void); +void BLI_threaded_malloc_begin(void); +void BLI_threaded_malloc_end(void); /* System Information */ @@ -91,8 +91,8 @@ int BLI_system_num_threads_override_get(void); #define LOCK_FFTW 9 #define LOCK_VIEW3D 10 -void BLI_lock_thread(int type); -void BLI_unlock_thread(int type); +void BLI_thread_lock(int type); +void BLI_thread_unlock(int type); /* Mutex Lock */ diff --git a/source/blender/blenlib/intern/task.c b/source/blender/blenlib/intern/task.c index c892ffbfd4a..53c0c560c0d 100644 --- a/source/blender/blenlib/intern/task.c +++ b/source/blender/blenlib/intern/task.c @@ -696,7 +696,7 @@ static TaskPool *task_pool_create_ex(TaskScheduler *scheduler, * and malloc could be non-thread safe at this point because * no other jobs are running. */ - BLI_begin_threaded_malloc(); + BLI_threaded_malloc_begin(); return pool; } @@ -763,7 +763,7 @@ void BLI_task_pool_free(TaskPool *pool) MEM_freeN(pool); - BLI_end_threaded_malloc(); + BLI_threaded_malloc_end(); } BLI_INLINE bool task_can_use_local_queues(TaskPool *pool, int thread_id) diff --git a/source/blender/blenlib/intern/threads.c b/source/blender/blenlib/intern/threads.c index 9dc458fa0b9..761f3982e28 100644 --- a/source/blender/blenlib/intern/threads.c +++ b/source/blender/blenlib/intern/threads.c @@ -83,13 +83,13 @@ static TaskScheduler *task_scheduler = NULL; * int maxthreads = 2; * int cont = 1; * - * BLI_init_threads(&lb, do_something_func, maxthreads); + * BLI_threadpool_init(&lb, do_something_func, maxthreads); * * while (cont) { * if (BLI_available_threads(&lb) && !(escape loop event)) { * // get new job (data pointer) * // tag job 'processed - * BLI_insert_thread(&lb, job); + * BLI_threadpool_insert(&lb, job); * } * else PIL_sleep_ms(50); * @@ -98,7 +98,7 @@ static TaskScheduler *task_scheduler = NULL; * for (go over all jobs) * if (job is ready) { * if (job was not removed) { - * BLI_remove_thread(&lb, job); + * BLI_threadpool_remove(&lb, job); * } * } * else cont = 1; @@ -110,7 +110,7 @@ static TaskScheduler *task_scheduler = NULL; * } * } * - * BLI_end_threads(&lb); + * BLI_threadpool_end(&lb); * ************************************************ */ static SpinLock _malloc_lock; @@ -183,7 +183,7 @@ TaskScheduler *BLI_task_scheduler_get(void) * problem otherwise: scene render will kill of the mutex! */ -void BLI_init_threads(ListBase *threadbase, void *(*do_thread)(void *), int tot) +void BLI_threadpool_init(ListBase *threadbase, void *(*do_thread)(void *), int tot) { int a; @@ -228,7 +228,7 @@ int BLI_available_threads(ListBase *threadbase) } /* returns thread number, for sample patterns or threadsafe tables */ -int BLI_available_thread_index(ListBase *threadbase) +int BLI_threadpool_available_thread_index(ListBase *threadbase) { ThreadSlot *tslot; int counter = 0; @@ -258,7 +258,7 @@ int BLI_thread_is_main(void) return pthread_equal(pthread_self(), mainid); } -void BLI_insert_thread(ListBase *threadbase, void *callerdata) +void BLI_threadpool_insert(ListBase *threadbase, void *callerdata) { ThreadSlot *tslot; @@ -273,7 +273,7 @@ void BLI_insert_thread(ListBase *threadbase, void *callerdata) printf("ERROR: could not insert thread slot\n"); } -void BLI_remove_thread(ListBase *threadbase, void *callerdata) +void BLI_threadpool_remove(ListBase *threadbase, void *callerdata) { ThreadSlot *tslot; @@ -286,7 +286,7 @@ void BLI_remove_thread(ListBase *threadbase, void *callerdata) } } -void BLI_remove_thread_index(ListBase *threadbase, int index) +void BLI_threadpool_remove_index(ListBase *threadbase, int index) { ThreadSlot *tslot; int counter = 0; @@ -301,7 +301,7 @@ void BLI_remove_thread_index(ListBase *threadbase, int index) } } -void BLI_remove_threads(ListBase *threadbase) +void BLI_threadpool_clear(ListBase *threadbase) { ThreadSlot *tslot; @@ -314,7 +314,7 @@ void BLI_remove_threads(ListBase *threadbase) } } -void BLI_end_threads(ListBase *threadbase) +void BLI_threadpool_end(ListBase *threadbase) { ThreadSlot *tslot; @@ -418,12 +418,12 @@ static ThreadMutex *global_mutex_from_type(const int type) } } -void BLI_lock_thread(int type) +void BLI_thread_lock(int type) { pthread_mutex_lock(global_mutex_from_type(type)); } -void BLI_unlock_thread(int type) +void BLI_thread_unlock(int type) { pthread_mutex_unlock(global_mutex_from_type(type)); } @@ -819,7 +819,7 @@ void BLI_thread_queue_wait_finish(ThreadQueue *queue) /* ************************************************ */ -void BLI_begin_threaded_malloc(void) +void BLI_threaded_malloc_begin(void) { unsigned int level = atomic_fetch_and_add_u(&thread_levels, 1); if (level == 0) { @@ -832,7 +832,7 @@ void BLI_begin_threaded_malloc(void) } } -void BLI_end_threaded_malloc(void) +void BLI_threaded_malloc_end(void) { unsigned int level = atomic_sub_and_fetch_u(&thread_levels, 1); if (level == 0) { |