MCPcopy Create free account
hub / github.com/HandBrake/HandBrake / taskset_init

Function taskset_init

libhb/taskset.c:16–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14static void taskset_thread_f( void *thread_args_v );
15
16int
17taskset_init( taskset_t *ts, const char *descr, int thread_count, size_t arg_size, thread_func_t *work_func)
18{
19 int init_step, i;
20
21 init_step = 0;
22 memset( ts, 0, sizeof( *ts ) );
23 ts->work_func = work_func;
24 ts->thread_count = thread_count;
25 ts->task_descr = descr;
26
27 ts->arg_size = arg_size;
28
29 if( arg_size != 0 )
30 {
31 ts->task_threads_args = malloc( arg_size * ts->thread_count );
32 if( ts->task_threads_args == NULL )
33 goto fail;
34 }
35 /*
36 * Initialize all arg data to 0.
37 */
38 memset(ts->task_threads_args, 0, ts->arg_size * ts->thread_count );
39
40 init_step++;
41
42 ts->task_thread_started = 0;
43 ts->task_threads = calloc( ts->thread_count, sizeof( taskset_thread_t) );
44 if( ts->task_threads == NULL )
45 goto fail;
46
47 init_step++;
48
49 for ( i = 0; i < ts->thread_count; i++ ) {
50 taskset_thread_t *thread = &ts->task_threads[i];
51
52 thread->lock = hb_lock_init();
53 if ( thread->lock == NULL )
54 goto fail;
55
56 thread->begin_cond = hb_cond_init();
57 if ( thread->begin_cond == NULL )
58 goto fail;
59
60 thread->complete_cond = hb_cond_init();
61 if ( thread->complete_cond == NULL )
62 goto fail;
63 }
64 return (1);
65
66fail:
67 switch (init_step)
68 {
69 default:
70 case 3:
71 for ( i = 0; i < ts->thread_count; i++ ) {
72 taskset_thread_t *thread = &ts->task_threads[i];
73 if ( thread->begin_cond )

Callers 4

comb_detect_initFunction · 0.85
hb_decomb_initFunction · 0.85
nlmeans_initFunction · 0.85
mt_frame_initFunction · 0.85

Calls 4

hb_lock_initFunction · 0.85
hb_cond_initFunction · 0.85
hb_cond_closeFunction · 0.85
hb_lock_closeFunction · 0.85

Tested by

no test coverage detected