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