-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsched.h
More file actions
35 lines (27 loc) · 715 Bytes
/
sched.h
File metadata and controls
35 lines (27 loc) · 715 Bytes
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
34
35
#ifndef SCHED_H_
#define SCHED_H_
#ifdef __cplusplus
extern "C" {
#endif
struct Task;
struct task_api {
int (*run)(struct Task *task);
void (*destruct)(struct Task *task);
};
#define TASK_DATA(TASK) ((Task*)(TASK)->data)
typedef struct Task {
struct task_api api;
void *data;
int *join;
} Task;
struct Task *Task_new(void *data, struct task_api *api);
struct Scheduler;
typedef struct Scheduler Scheduler;
struct Scheduler *Scheduler_new(unsigned max_workers);
void Scheduler_delete(struct Scheduler *sched);
void Scheduler_enqueue(struct Scheduler *sched, struct Task *task);
void Scheduler_join(struct Scheduler *sched);
#ifdef __cplusplus
}
#endif
#endif /* end of include guard */