4coder/custom/4coder_async_tasks.h

57 lines
1.0 KiB
C
Raw Normal View History

2019-10-21 02:02:58 +00:00
/*
* 4coder_async_tasks.cpp - Types for the custom layer asynchronous task system.
*/
// TOP
#if !defined(FCODER_ASYNC_TASKS_H)
#define FCODER_ASYNC_TASKS_H
typedef void Async_Task_Function_Type(struct Async_Context *actx, Data data);
2019-10-21 02:02:58 +00:00
typedef u64 Async_Task;
struct Async_Thread{
2019-10-22 05:17:24 +00:00
struct Async_System *async_system;
2019-10-22 05:53:47 +00:00
System_Thread thread;
struct Async_Node *node;
Async_Task task;
2019-10-22 05:17:24 +00:00
b32 cancel_signal;
};
struct Async_Node{
2019-10-22 05:17:24 +00:00
union{
Async_Node *next;
Node node;
};
Async_Task task;
Async_Thread *thread;
Async_Task_Function_Type *func;
Data data;
};
struct Async_System{
void *cmd_context;
Heap node_heap;
Arena node_arena;
System_Mutex mutex;
System_Condition_Variable cv;
2019-10-22 05:17:24 +00:00
System_Condition_Variable join_cv;
Async_Task task_id_counter;
Async_Node *free_nodes;
2019-10-22 05:17:24 +00:00
Node task_sent;
i32 task_count;
Async_Thread thread;
};
struct Async_Context{
Application_Links *app;
Async_Thread *thread;
};
2019-10-21 02:02:58 +00:00
#endif
// BOTTOM