FFmpeg
executor.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2023 Nuo Mi
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #ifndef AVUTIL_EXECUTOR_H
22 #define AVUTIL_EXECUTOR_H
23 
24 typedef struct AVExecutor AVExecutor;
25 typedef struct AVTask AVTask;
26 
27 struct AVTask {
29 };
30 
31 typedef struct AVTaskCallbacks {
32  void *user_data;
33 
35 
36  // return 1 if a's priority > b's priority
37  int (*priority_higher)(const AVTask *a, const AVTask *b);
38 
39  // task is ready for run
40  int (*ready)(const AVTask *t, void *user_data);
41 
42  // run the task
43  int (*run)(AVTask *t, void *local_context, void *user_data);
45 
46 /**
47  * Alloc executor
48  * @param callbacks callback structure for executor
49  * @param thread_count worker thread number, 0 for run on caller's thread directly
50  * @return return the executor
51  */
52 AVExecutor* av_executor_alloc(const AVTaskCallbacks *callbacks, int thread_count);
53 
54 /**
55  * Free executor
56  * @param e pointer to executor
57  */
59 
60 /**
61  * Add task to executor
62  * @param e pointer to executor
63  * @param t pointer to task. If NULL, it will wakeup one work thread
64  */
66 
67 #endif //AVUTIL_EXECUTOR_H
callbacks
static const OMX_CALLBACKTYPE callbacks
Definition: omx.c:340
AVTask::next
AVTask * next
Definition: executor.h:28
b
#define b
Definition: input.c:41
av_executor_execute
void av_executor_execute(AVExecutor *e, AVTask *t)
Add task to executor.
Definition: executor.c:195
AVTaskCallbacks
Definition: executor.h:31
AVTaskCallbacks::local_context_size
int local_context_size
Definition: executor.h:34
AVTaskCallbacks::ready
int(* ready)(const AVTask *t, void *user_data)
Definition: executor.h:40
AVTaskCallbacks::run
int(* run)(AVTask *t, void *local_context, void *user_data)
Definition: executor.h:43
AVTask
Definition: executor.h:27
av_executor_alloc
AVExecutor * av_executor_alloc(const AVTaskCallbacks *callbacks, int thread_count)
Alloc executor.
Definition: executor.c:142
AVExecutor
Definition: executor.c:51
av_executor_free
void av_executor_free(AVExecutor **e)
Free executor.
Definition: executor.c:184
a
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
Definition: undefined.txt:41
AVTaskCallbacks::user_data
void * user_data
Definition: executor.h:32
AVTaskCallbacks::priority_higher
int(* priority_higher)(const AVTask *a, const AVTask *b)
Definition: executor.h:37