2 * Copyright (C) 2023 Nuo Mi
4 * This file is part of FFmpeg.
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.
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.
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
21 #ifndef AVUTIL_EXECUTOR_H
22 #define AVUTIL_EXECUTOR_H
24 typedef struct AVExecutor AVExecutor;
25 typedef struct AVTask AVTask;
31 typedef struct AVTaskCallbacks {
34 int local_context_size;
36 // return 1 if a's priority > b's priority
37 int (*priority_higher)(const AVTask *a, const AVTask *b);
39 // task is ready for run
40 int (*ready)(const AVTask *t, void *user_data);
43 int (*run)(AVTask *t, void *local_context, void *user_data);
48 * @param callbacks callback structure for executor
49 * @param thread_count worker thread number
50 * @return return the executor
52 AVExecutor* av_executor_alloc(const AVTaskCallbacks *callbacks, int thread_count);
56 * @param e pointer to executor
58 void av_executor_free(AVExecutor **e);
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
65 void av_executor_execute(AVExecutor *e, AVTask *t);
67 #endif //AVUTIL_EXECUTOR_H