duckstation

duckstation, but archived from the revision just before upstream changed it to a proprietary software project, this version is the libre one
git clone https://git.neptards.moe/u3shit/duckstation.git
Log | Files | Refs | README | LICENSE

executor.h (1885B)


      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 {
     28     AVTask *next;
     29 };
     30 
     31 typedef struct AVTaskCallbacks {
     32     void *user_data;
     33 
     34     int local_context_size;
     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);
     44 } AVTaskCallbacks;
     45 
     46 /**
     47  * Alloc executor
     48  * @param callbacks callback structure for executor
     49  * @param thread_count worker thread number
     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  */
     58 void av_executor_free(AVExecutor **e);
     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  */
     65 void av_executor_execute(AVExecutor *e, AVTask *t);
     66 
     67 #endif //AVUTIL_EXECUTOR_H