Blender V2.61 - r43446
Classes | Defines | Typedefs | Functions | Variables

threads.c File Reference

#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)
ThreadedWorkerBLI_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)
ThreadQueueBLI_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

Detailed Description

Definition in file threads.c.


Define Documentation

#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 Documentation

typedef struct ThreadSlot ThreadSlot
typedef struct WorkParam WorkParam

Function Documentation

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)
void BLI_begin_threaded_malloc ( void  )
ThreadedWorker* BLI_create_worker ( void *(*)(void *)  do_thread,
int  tot,
int  sleep_time 
) [read]
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)
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 
)
void BLI_insert_thread ( ListBase threadbase,
void *  callerdata 
)
void BLI_insert_work ( ThreadedWorker worker,
void *  param 
)
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)
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)
void BLI_mutex_unlock ( ThreadMutex mutex)
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_rw_mutex_end ( ThreadRWMutex mutex)

Definition at line 420 of file threads.c.

Referenced by RE_FreeRender().

void BLI_rw_mutex_init ( ThreadRWMutex mutex)

Definition at line 402 of file threads.c.

References NULL.

Referenced by RE_NewRender().

void BLI_rw_mutex_lock ( ThreadRWMutex mutex,
int  mode 
)
void BLI_rw_mutex_unlock ( ThreadRWMutex mutex)
int BLI_system_thread_count ( void  )
int BLI_thread_is_main ( void  )
void BLI_thread_queue_free ( ThreadQueue queue)
ThreadQueue* BLI_thread_queue_init ( void  )
void BLI_thread_queue_nowait ( ThreadQueue queue)
void* BLI_thread_queue_pop ( ThreadQueue queue)
void* BLI_thread_queue_pop_timeout ( ThreadQueue queue,
int  ms 
)
void BLI_thread_queue_push ( ThreadQueue queue,
void *  work 
)
int BLI_thread_queue_size ( ThreadQueue queue)
void BLI_threadapi_init ( void  )

Definition at line 142 of file threads.c.

References mainid.

Referenced by main().

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)
static void* exec_work_fnct ( void *  v_param) [static]
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().


Variable Documentation

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]