~vladh/peony

peony/src/tasks.hpp -rw-r--r-- 616 bytes
7fc9922bVlad-Stefan Harbuz changes shaders namespace into class a month ago
                                                                                
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
/*
  Peony Game Engine
  Copyright (C) 2020 Vlad-Stefan Harbuz <vlad@vladh.net>
  All rights reserved.
*/

#pragma once

#include <mutex>
#include "types.hpp"
#include "queue.hpp"

namespace tasks {
  typedef void (*TaskFn)(void*, void*);
  struct Task {
    TaskFn fn;
    void *argument_1;
    void *argument_2;
  };
  struct TasksState {
    Queue<Task> task_queue;
  };

  void run_loading_loop(
    TasksState *tasks_state,
    std::mutex *mutex,
    bool32 *should_stop,
    uint32 idx_thread
  );
  void init(TasksState *tasks_state, MemoryPool *pool);
}

using tasks::Task, tasks::TaskFn, tasks::TasksState;