FFmpeg 7.1.1
Loading...
Searching...
No Matches
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
24typedef struct AVExecutor AVExecutor;
25typedef struct AVTask AVTask;
26
27struct AVTask {
29};
30
31typedef 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 */
52AVExecutor* 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
void av_executor_free(AVExecutor **e)
Free executor.
AVExecutor * av_executor_alloc(const AVTaskCallbacks *callbacks, int thread_count)
Alloc executor.
struct AVExecutor AVExecutor
Definition executor.h:24
void av_executor_execute(AVExecutor *e, AVTask *t)
Add task to executor.
int(* priority_higher)(const AVTask *a, const AVTask *b)
Definition executor.h:37
int local_context_size
Definition executor.h:34
int(* ready)(const AVTask *t, void *user_data)
Definition executor.h:40
int(* run)(AVTask *t, void *local_context, void *user_data)
Definition executor.h:43
void * user_data
Definition executor.h:32
AVTask * next
Definition executor.h:28