WinGui: Fix another instance of the Caliburn vs Json.net sillyness where objects...
[HandBrake.git] / libhb / taskset.h
blob12b86fe74bf3169ff093b489870de6ced2776206
1 /* taskset.h
3 Copyright (c) 2003-2015 HandBrake Team
4 This file is part of the HandBrake source code
5 Homepage: <http://handbrake.fr/>.
6 It may be used under the terms of the GNU General Public License v2.
7 For full terms see the file COPYING file or visit http://www.gnu.org/licenses/gpl-2.0.html
8 */
10 #ifndef HB_TASKSET_H
11 #define HB_TASKSET_H
13 #define TASKSET_POSIX_COMPLIANT 1
15 #include "bits.h"
17 typedef struct hb_taskset_s {
18 int thread_count;
19 int arg_size;
20 int bitmap_elements;
21 hb_thread_t ** task_threads;
22 uint8_t * task_threads_args;
23 uint32_t * task_begin_bitmap; // Threads can begin
24 uint32_t * task_complete_bitmap; // Threads have completed
25 uint32_t * task_stop_bitmap; // Threads should exit
26 hb_lock_t * task_cond_lock; // Held during condition tests
27 hb_cond_t * task_begin; // Threads can begin work
28 hb_cond_t * task_complete; // Threads have finished work.
29 } taskset_t;
31 int taskset_init( taskset_t *, int /*thread_count*/, size_t /*user_arg_size*/ );
32 void taskset_cycle( taskset_t * );
33 void taskset_fini( taskset_t * );
35 int taskset_thread_spawn( taskset_t *, int /*thr_idx*/, const char * /*descr*/,
36 thread_func_t *, int /*priority*/ );
37 void taskset_thread_wait4start( taskset_t *, int );
38 void taskset_thread_complete( taskset_t *, int );
40 static inline void *taskset_thread_args( taskset_t *, int );
41 static inline int taskset_thread_stop( taskset_t *, int );
43 static inline void *
44 taskset_thread_args( taskset_t *ts, int thr_idx )
46 return( ts->task_threads_args + ( ts->arg_size * thr_idx ) );
49 static inline int
50 taskset_thread_stop( taskset_t *ts, int thr_idx )
52 return bit_is_set( ts->task_stop_bitmap, thr_idx );
55 #endif /* HB_TASKSET_H */