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

Function taskset_cycle

libhb/taskset.c:99–139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

97}
98
99void
100taskset_cycle( taskset_t *ts )
101{
102 int i;
103 if ( !ts->task_thread_started ) {
104 for ( i = 0; i < ts->thread_count; i++ ) {
105 taskset_thread_t *thread = taskset_thread( ts, i );
106 thread->thread = hb_thread_init( ts->task_descr, taskset_thread_f,
107 taskset_thread_args( ts, i ),
108 HB_NORMAL_PRIORITY );
109 }
110 ts->task_thread_started = 1;
111 }
112
113 /*
114 * Signal all threads that their work is available.
115 */
116 for (i = 0; i < ts->thread_count; i++) {
117 taskset_thread_t *thread = taskset_thread( ts, i );
118 hb_lock( thread->lock );
119 thread->begin = 1;
120 hb_cond_signal( thread->begin_cond );
121 hb_unlock( thread->lock );
122 }
123
124 /*
125 * Wait until all threads have completed. Note that we must
126 * loop here as hb_cond_wait() on some platforms (e.g pthread_cond_wait)
127 * may unblock prematurely.
128 */
129 for ( i = 0; i < ts->thread_count; i++ )
130 {
131 taskset_thread_t *thread = taskset_thread( ts, i );
132 hb_lock( thread->lock );
133 while (!thread->complete) {
134 hb_cond_wait( thread->complete_cond, thread->lock);
135 }
136 thread->complete = 0;
137 hb_unlock( thread->lock );
138 }
139}
140
141/*
142 * Block current thread until work is available for it.

Callers 5

comb_segmenterFunction · 0.85
nlmeans_filterFunction · 0.85
mt_frame_filterFunction · 0.85
FUNC(eedi2_planer)Function · 0.85
FUNC(filter)Function · 0.85

Calls 7

taskset_threadFunction · 0.85
hb_thread_initFunction · 0.85
taskset_thread_argsFunction · 0.85
hb_lockFunction · 0.85
hb_cond_signalFunction · 0.85
hb_unlockFunction · 0.85
hb_cond_waitFunction · 0.85

Tested by

no test coverage detected