Blender V2.61 - r43446
|
#include <errno.h>
#include <string.h>
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_gsqueue.h"
#include "BLI_threads.h"
#include "PIL_time.h"
#include <unistd.h>
#include <sys/time.h>
Go to the source code of this file.
Classes | |
struct | ThreadSlot |
struct | ThreadedWorker |
struct | WorkParam |
class | ThreadQueue< T > |
Defines | |
#define | RE_MAX_THREAD BLENDER_MAX_THREADS |
Typedefs | |
typedef struct ThreadSlot | ThreadSlot |
typedef struct ThreadedWorker | ThreadedWorker |
typedef struct WorkParam | WorkParam |
Functions | |
static void | BLI_lock_malloc_thread (void) |
static void | BLI_unlock_malloc_thread (void) |
void | BLI_threadapi_init (void) |
void | BLI_init_threads (ListBase *threadbase, void *(*do_thread)(void *), int tot) |
int | BLI_available_threads (ListBase *threadbase) |
int | BLI_available_thread_index (ListBase *threadbase) |
static void * | tslot_thread_start (void *tslot_p) |
int | BLI_thread_is_main (void) |
void | BLI_insert_thread (ListBase *threadbase, void *callerdata) |
void | BLI_remove_thread (ListBase *threadbase, void *callerdata) |
void | BLI_remove_thread_index (ListBase *threadbase, int index) |
void | BLI_remove_threads (ListBase *threadbase) |
void | BLI_end_threads (ListBase *threadbase) |
int | BLI_system_thread_count (void) |
void | BLI_lock_thread (int type) |
void | BLI_unlock_thread (int type) |
void | BLI_mutex_init (ThreadMutex *mutex) |
void | BLI_mutex_lock (ThreadMutex *mutex) |
void | BLI_mutex_unlock (ThreadMutex *mutex) |
void | BLI_mutex_end (ThreadMutex *mutex) |
void | BLI_rw_mutex_init (ThreadRWMutex *mutex) |
void | BLI_rw_mutex_lock (ThreadRWMutex *mutex, int mode) |
void | BLI_rw_mutex_unlock (ThreadRWMutex *mutex) |
void | BLI_rw_mutex_end (ThreadRWMutex *mutex) |
static void * | exec_work_fnct (void *v_param) |
ThreadedWorker * | BLI_create_worker (void *(*do_thread)(void *), int tot, int sleep_time) |
void | BLI_end_worker (ThreadedWorker *worker) |
void | BLI_destroy_worker (ThreadedWorker *worker) |
void | BLI_insert_work (ThreadedWorker *worker, void *param) |
ThreadQueue * | BLI_thread_queue_init (void) |
void | BLI_thread_queue_free (ThreadQueue *queue) |
void | BLI_thread_queue_push (ThreadQueue *queue, void *work) |
void * | BLI_thread_queue_pop (ThreadQueue *queue) |
static void | wait_timeout (struct timespec *timeout, int ms) |
void * | BLI_thread_queue_pop_timeout (ThreadQueue *queue, int ms) |
int | BLI_thread_queue_size (ThreadQueue *queue) |
void | BLI_thread_queue_nowait (ThreadQueue *queue) |
void | BLI_begin_threaded_malloc (void) |
void | BLI_end_threaded_malloc (void) |
Variables | |
static pthread_mutex_t | _malloc_lock = PTHREAD_MUTEX_INITIALIZER |
static pthread_mutex_t | _image_lock = PTHREAD_MUTEX_INITIALIZER |
static pthread_mutex_t | _preview_lock = PTHREAD_MUTEX_INITIALIZER |
static pthread_mutex_t | _viewer_lock = PTHREAD_MUTEX_INITIALIZER |
static pthread_mutex_t | _custom1_lock = PTHREAD_MUTEX_INITIALIZER |
static pthread_mutex_t | _rcache_lock = PTHREAD_MUTEX_INITIALIZER |
static pthread_mutex_t | _opengl_lock = PTHREAD_MUTEX_INITIALIZER |
static pthread_mutex_t | _nodes_lock = PTHREAD_MUTEX_INITIALIZER |
static pthread_mutex_t | _movieclip_lock = PTHREAD_MUTEX_INITIALIZER |
static pthread_t | mainid |
static int | thread_levels = 0 |
Definition in file threads.c.
#define RE_MAX_THREAD BLENDER_MAX_THREADS |
Definition at line 122 of file threads.c.
Referenced by BLI_create_worker(), BLI_init_threads(), and BLI_system_thread_count().
typedef struct ThreadedWorker ThreadedWorker |
typedef struct ThreadSlot ThreadSlot |
int BLI_available_thread_index | ( | ListBase * | threadbase | ) |
Definition at line 197 of file threads.c.
References ThreadSlot::avail, ListBase::first, and ThreadSlot::next.
Referenced by BLI_insert_work(), and threaded_tile_processor().
int BLI_available_threads | ( | ListBase * | threadbase | ) |
Definition at line 184 of file threads.c.
References ThreadSlot::avail, ListBase::first, and ThreadSlot::next.
Referenced by BLI_insert_work(), ntreeCompositExecTree(), and threaded_tile_processor().
void BLI_begin_threaded_malloc | ( | void | ) |
Definition at line 672 of file threads.c.
References BLI_lock_malloc_thread(), BLI_unlock_malloc_thread(), MEM_set_lock_callback(), and thread_levels.
Referenced by BKE_tracking_context_new(), and dynamicPaint_paintParticles().
ThreadedWorker* BLI_create_worker | ( | void *(*)(void *) | do_thread, |
int | tot, | ||
int | sleep_time | ||
) | [read] |
Definition at line 454 of file threads.c.
References BLI_init_threads(), exec_work_fnct(), MEM_callocN(), RE_MAX_THREAD, ThreadedWorker::threadbase, ThreadedWorker::total, and ThreadedWorker::work_fnct.
Referenced by newRigGraph().
void BLI_destroy_worker | ( | ThreadedWorker * | worker | ) |
Definition at line 484 of file threads.c.
References BLI_end_worker(), BLI_freelistN(), MEM_freeN(), and ThreadedWorker::threadbase.
Referenced by RIG_freeRigGraph().
void BLI_end_threaded_malloc | ( | void | ) |
Definition at line 680 of file threads.c.
References MEM_set_lock_callback(), NULL, and thread_levels.
Referenced by BKE_tracking_context_free(), and dynamicPaint_paintParticles().
void BLI_end_threads | ( | ListBase * | threadbase | ) |
Definition at line 283 of file threads.c.
References ThreadSlot::avail, BLI_freelistN(), ListBase::first, MEM_set_lock_callback(), ThreadSlot::next, NULL, ThreadSlot::pthread, and thread_levels.
Referenced by bake_image_exec(), BKE_ptcache_bake(), distribute_particles_on_dm(), make_occ_tree(), ntreeCompositExecTree(), occ_build_recursive(), project_paint_op(), psys_cache_child_paths(), RE_bake_shade_all_selected(), sb_cf_threads_run(), sb_sfesf_threads_run(), threaded_makeshadowbufs(), threaded_tile_processor(), vol_precache_objectinstance_threads(), wm_jobs_kill_job(), and wm_jobs_timer().
void BLI_end_worker | ( | ThreadedWorker * | worker | ) |
Definition at line 479 of file threads.c.
References BLI_remove_threads(), and ThreadedWorker::threadbase.
Referenced by BLI_destroy_worker(), and finishRetarget().
void BLI_init_threads | ( | ListBase * | threadbase, |
void *(*)(void *) | do_thread, | ||
int | tot | ||
) |
Definition at line 151 of file threads.c.
References ThreadSlot::avail, BLI_addtail(), BLI_lock_malloc_thread(), BLI_unlock_malloc_thread(), ThreadSlot::do_thread, ListBase::first, ListBase::last, MEM_callocN(), MEM_set_lock_callback(), NULL, RE_MAX_THREAD, and thread_levels.
Referenced by bake_image_exec(), BKE_ptcache_bake(), BLI_create_worker(), distribute_particles_on_dm(), make_occ_tree(), ntreeCompositExecTree(), occ_build_recursive(), project_paint_op(), psys_cache_child_paths(), RE_bake_shade_all_selected(), sb_cf_threads_run(), sb_sfesf_threads_run(), threaded_makeshadowbufs(), threaded_tile_processor(), vol_precache_objectinstance_threads(), and WM_jobs_start().
void BLI_insert_thread | ( | ListBase * | threadbase, |
void * | callerdata | ||
) |
Definition at line 227 of file threads.c.
References ThreadSlot::avail, ThreadSlot::callerdata, ListBase::first, ThreadSlot::next, NULL, ThreadSlot::pthread, and tslot_thread_start().
Referenced by bake_image_exec(), BKE_ptcache_bake(), BLI_insert_work(), distribute_particles_on_dm(), make_occ_tree(), ntreeCompositExecTree(), occ_build_recursive(), project_paint_op(), psys_cache_child_paths(), RE_bake_shade_all_selected(), sb_cf_threads_run(), sb_sfesf_threads_run(), threaded_makeshadowbufs(), threaded_tile_processor(), vol_precache_objectinstance_threads(), and WM_jobs_start().
void BLI_insert_work | ( | ThreadedWorker * | worker, |
void * | param | ||
) |
Definition at line 491 of file threads.c.
References BLI_available_thread_index(), BLI_available_threads(), BLI_insert_thread(), BLI_remove_thread_index(), ThreadedWorker::busy, WorkParam::index, MEM_callocN(), p, WorkParam::param, PIL_sleep_ms(), ThreadedWorker::sleep_time, ThreadedWorker::threadbase, ThreadedWorker::total, and WorkParam::worker.
Referenced by retargetArctoArc().
static void BLI_lock_malloc_thread | ( | void | ) | [static] |
Definition at line 132 of file threads.c.
References _malloc_lock.
Referenced by BLI_begin_threaded_malloc(), and BLI_init_threads().
void BLI_lock_thread | ( | int | type | ) |
Definition at line 338 of file threads.c.
References _custom1_lock, _image_lock, _movieclip_lock, _nodes_lock, _opengl_lock, _preview_lock, _rcache_lock, _viewer_lock, LOCK_CUSTOM1, LOCK_IMAGE, LOCK_MOVIECLIP, LOCK_NODES, LOCK_OPENGL, LOCK_PREVIEW, LOCK_RCACHE, and LOCK_VIEWER.
Referenced by BKE_image_acquire_ibuf(), colorfn(), do_shadow_thread(), envmap_split_ima(), generate_preview(), get_next_bake_face(), GPU_free_unused_buffers(), gpu_queue_image_for_free(), image_get_render_result(), image_mipmap_test(), makeshadowbuf(), movieclip_build_proxy_ibuf(), movieclip_get_postprocessed_ibuf(), node_draw_basis(), node_update_basis(), ntreeShaderExecTree(), ntreeTexExecTree(), occ_build_recursive(), project_bucket_iter_next(), project_paint_face_init(), render_realtime_texture(), save_render_result_tile(), sculpt_undo_push_node(), shade_tface(), sss_add_points(), and threaded_makeshadowbufs().
void BLI_mutex_end | ( | ThreadMutex * | mutex | ) |
Definition at line 395 of file threads.c.
Referenced by imb_tile_cache_exit(), and proxy_freejob().
void BLI_mutex_init | ( | ThreadMutex * | mutex | ) |
Definition at line 380 of file threads.c.
References NULL.
Referenced by imb_tile_cache_init(), IMB_tile_cache_params(), and seq_proxy_build_job().
void BLI_mutex_lock | ( | ThreadMutex * | mutex | ) |
Definition at line 385 of file threads.c.
Referenced by imb_global_cache_get_tile(), imb_tile_cache_tile_free(), IMB_tiles_to_rect(), proxy_startjob(), and seq_proxy_build_job().
void BLI_mutex_unlock | ( | ThreadMutex * | mutex | ) |
Definition at line 390 of file threads.c.
Referenced by imb_global_cache_get_tile(), imb_tile_cache_tile_free(), IMB_tiles_to_rect(), proxy_startjob(), and seq_proxy_build_job().
void BLI_remove_thread | ( | ListBase * | threadbase, |
void * | callerdata | ||
) |
Definition at line 242 of file threads.c.
References ThreadSlot::avail, ThreadSlot::callerdata, ListBase::first, ThreadSlot::next, NULL, and ThreadSlot::pthread.
Referenced by ntreeCompositExecTree(), and threaded_tile_processor().
void BLI_remove_thread_index | ( | ListBase * | threadbase, |
int | index | ||
) |
Definition at line 255 of file threads.c.
References ThreadSlot::avail, ThreadSlot::callerdata, ListBase::first, ThreadSlot::next, NULL, and ThreadSlot::pthread.
Referenced by BLI_insert_work().
void BLI_remove_threads | ( | ListBase * | threadbase | ) |
Definition at line 270 of file threads.c.
References ThreadSlot::avail, ThreadSlot::callerdata, ListBase::first, ThreadSlot::next, NULL, and ThreadSlot::pthread.
Referenced by BLI_end_worker().
void BLI_rw_mutex_end | ( | ThreadRWMutex * | mutex | ) |
Definition at line 420 of file threads.c.
Referenced by RE_FreeRender().
void BLI_rw_mutex_init | ( | ThreadRWMutex * | mutex | ) |
void BLI_rw_mutex_lock | ( | ThreadRWMutex * | mutex, |
int | mode | ||
) |
Definition at line 407 of file threads.c.
References THREAD_LOCK_READ.
Referenced by do_merge_fullsample(), do_render_blur_3d(), do_render_composite_fields_blur_3d(), do_render_fields_3d(), do_render_fields_blur_3d(), do_render_seq(), RE_AcquireResultImage(), RE_AcquireResultRead(), RE_AcquireResultWrite(), RE_engine_render(), RE_InitState(), RE_ReadRenderResult(), render_initialize_from_main(), sss_create_tree_mat(), and threaded_tile_processor().
void BLI_rw_mutex_unlock | ( | ThreadRWMutex * | mutex | ) |
Definition at line 415 of file threads.c.
Referenced by do_merge_fullsample(), do_render_blur_3d(), do_render_composite_fields_blur_3d(), do_render_fields_3d(), do_render_fields_blur_3d(), do_render_seq(), RE_engine_render(), RE_InitState(), RE_ReadRenderResult(), RE_ReleaseResult(), RE_ReleaseResultImage(), render_initialize_from_main(), sss_create_tree_mat(), and threaded_tile_processor().
int BLI_system_thread_count | ( | void | ) |
Definition at line 307 of file threads.c.
References len(), NULL, and RE_MAX_THREAD.
Referenced by newRigGraph(), project_paint_begin(), psys_threads_create(), RE_init_threadcount(), RE_set_max_threads(), sb_cf_threads_run(), and sb_sfesf_threads_run().
int BLI_thread_is_main | ( | void | ) |
Definition at line 222 of file threads.c.
References mainid.
Referenced by ED_render_scene_update(), GPU_buffer_free(), GPU_free_image(), GPU_free_unused_buffers(), and seq_render_scene_strip_impl().
void BLI_thread_queue_free | ( | ThreadQueue * | queue | ) |
Definition at line 549 of file threads.c.
References BLI_gsqueue_free(), ThreadQueue< T >::cond, MEM_freeN(), ThreadQueue< T >::mutex, and ThreadQueue< T >::queue.
Referenced by vol_precache_objectinstance_threads().
ThreadQueue* BLI_thread_queue_init | ( | void | ) |
Definition at line 536 of file threads.c.
References BLI_gsqueue_new(), ThreadQueue< T >::cond, MEM_callocN(), ThreadQueue< T >::mutex, NULL, and ThreadQueue< T >::queue.
Referenced by vol_precache_objectinstance_threads().
void BLI_thread_queue_nowait | ( | ThreadQueue * | queue | ) |
Definition at line 661 of file threads.c.
References ThreadQueue< T >::cond, ThreadQueue< T >::mutex, and ThreadQueue< T >::nowait.
Referenced by vol_precache_objectinstance_threads().
void* BLI_thread_queue_pop | ( | ThreadQueue * | queue | ) |
Definition at line 570 of file threads.c.
References BLI_gsqueue_is_empty(), BLI_gsqueue_pop(), ThreadQueue< T >::cond, ThreadQueue< T >::mutex, ThreadQueue< T >::nowait, NULL, and ThreadQueue< T >::queue.
Referenced by vol_precache_part().
void* BLI_thread_queue_pop_timeout | ( | ThreadQueue * | queue, |
int | ms | ||
) |
Definition at line 623 of file threads.c.
References BLI_gsqueue_is_empty(), BLI_gsqueue_pop(), ThreadQueue< T >::cond, ThreadQueue< T >::mutex, ThreadQueue< T >::nowait, NULL, PIL_check_seconds_timer(), ThreadQueue< T >::queue, and wait_timeout().
Referenced by vol_precache_objectinstance_threads().
void BLI_thread_queue_push | ( | ThreadQueue * | queue, |
void * | work | ||
) |
Definition at line 559 of file threads.c.
References BLI_gsqueue_push(), ThreadQueue< T >::cond, ThreadQueue< T >::mutex, and ThreadQueue< T >::queue.
Referenced by vol_precache_objectinstance_threads(), and vol_precache_part().
int BLI_thread_queue_size | ( | ThreadQueue * | queue | ) |
Definition at line 650 of file threads.c.
References BLI_gsqueue_size(), ThreadQueue< T >::mutex, ThreadQueue< T >::queue, and size().
void BLI_threadapi_init | ( | void | ) |
static void BLI_unlock_malloc_thread | ( | void | ) | [static] |
Definition at line 137 of file threads.c.
References _malloc_lock.
Referenced by BLI_begin_threaded_malloc(), and BLI_init_threads().
void BLI_unlock_thread | ( | int | type | ) |
Definition at line 358 of file threads.c.
References _custom1_lock, _image_lock, _movieclip_lock, _nodes_lock, _opengl_lock, _preview_lock, _rcache_lock, _viewer_lock, LOCK_CUSTOM1, LOCK_IMAGE, LOCK_MOVIECLIP, LOCK_NODES, LOCK_OPENGL, LOCK_PREVIEW, LOCK_RCACHE, and LOCK_VIEWER.
Referenced by BKE_image_acquire_ibuf(), BKE_image_release_ibuf(), colorfn(), do_shadow_thread(), envmap_split_ima(), generate_preview(), get_next_bake_face(), GPU_free_unused_buffers(), gpu_queue_image_for_free(), image_mipmap_test(), makeshadowbuf(), movieclip_build_proxy_ibuf(), movieclip_get_postprocessed_ibuf(), node_draw_basis(), node_update_basis(), ntreeShaderExecTree(), ntreeTexExecTree(), occ_build_recursive(), project_bucket_iter_next(), project_paint_face_init(), render_realtime_texture(), save_render_result_tile(), sculpt_undo_push_node(), shade_tface(), sss_add_points(), and threaded_makeshadowbufs().
static void* exec_work_fnct | ( | void * | v_param | ) | [static] |
Definition at line 441 of file threads.c.
References ThreadedWorker::busy, WorkParam::index, MEM_freeN(), p, WorkParam::param, ThreadedWorker::work_fnct, and WorkParam::worker.
Referenced by BLI_create_worker().
static void* tslot_thread_start | ( | void * | tslot_p | ) | [static] |
Definition at line 209 of file threads.c.
References ThreadSlot::callerdata, and ThreadSlot::do_thread.
Referenced by BLI_insert_thread().
static void wait_timeout | ( | struct timespec * | timeout, |
int | ms | ||
) | [static] |
Definition at line 588 of file threads.c.
References NULL.
Referenced by BLI_thread_queue_pop_timeout().
pthread_mutex_t _custom1_lock = PTHREAD_MUTEX_INITIALIZER [static] |
Definition at line 113 of file threads.c.
Referenced by BLI_lock_thread(), and BLI_unlock_thread().
pthread_mutex_t _image_lock = PTHREAD_MUTEX_INITIALIZER [static] |
Definition at line 110 of file threads.c.
Referenced by BLI_lock_thread(), and BLI_unlock_thread().
pthread_mutex_t _malloc_lock = PTHREAD_MUTEX_INITIALIZER [static] |
Definition at line 109 of file threads.c.
Referenced by BLI_lock_malloc_thread(), and BLI_unlock_malloc_thread().
pthread_mutex_t _movieclip_lock = PTHREAD_MUTEX_INITIALIZER [static] |
Definition at line 117 of file threads.c.
Referenced by BLI_lock_thread(), and BLI_unlock_thread().
pthread_mutex_t _nodes_lock = PTHREAD_MUTEX_INITIALIZER [static] |
Definition at line 116 of file threads.c.
Referenced by BLI_lock_thread(), and BLI_unlock_thread().
pthread_mutex_t _opengl_lock = PTHREAD_MUTEX_INITIALIZER [static] |
Definition at line 115 of file threads.c.
Referenced by BLI_lock_thread(), and BLI_unlock_thread().
pthread_mutex_t _preview_lock = PTHREAD_MUTEX_INITIALIZER [static] |
Definition at line 111 of file threads.c.
Referenced by BLI_lock_thread(), and BLI_unlock_thread().
pthread_mutex_t _rcache_lock = PTHREAD_MUTEX_INITIALIZER [static] |
Definition at line 114 of file threads.c.
Referenced by BLI_lock_thread(), and BLI_unlock_thread().
pthread_mutex_t _viewer_lock = PTHREAD_MUTEX_INITIALIZER [static] |
Definition at line 112 of file threads.c.
Referenced by BLI_lock_thread(), and BLI_unlock_thread().
pthread_t mainid [static] |
Definition at line 118 of file threads.c.
Referenced by BLI_thread_is_main(), and BLI_threadapi_init().
int thread_levels = 0 [static] |
Definition at line 119 of file threads.c.
Referenced by BLI_begin_threaded_malloc(), BLI_end_threaded_malloc(), BLI_end_threads(), and BLI_init_threads().