]>
Commit | Line | Data |
---|---|---|
60918275 LP |
1 | /*-*- Mode: C; c-basic-offset: 8 -*-*/ |
2 | ||
3 | #ifndef foomanagerhfoo | |
4 | #define foomanagerhfoo | |
5 | ||
6 | #include <stdbool.h> | |
7 | #include <inttypes.h> | |
a66d02c3 | 8 | #include <stdio.h> |
60918275 LP |
9 | |
10 | typedef struct Manager Manager; | |
034c6ed7 | 11 | typedef enum ManagerEventType ManagerEventType; |
60918275 LP |
12 | |
13 | #include "name.h" | |
14 | #include "job.h" | |
15 | #include "hashmap.h" | |
16 | #include "list.h" | |
17 | #include "set.h" | |
18 | ||
034c6ed7 LP |
19 | enum ManagerEventType { |
20 | MANAGER_SIGNAL, | |
21 | MANAGER_FD, | |
22 | MANAGER_TIMER | |
23 | }; | |
24 | ||
60918275 LP |
25 | struct Manager { |
26 | uint32_t current_job_id; | |
27 | ||
87d1515d LP |
28 | /* Note that the set of names we know of is allowed to be |
29 | * incosistent. However the subset of it that is loaded may | |
30 | * not, and the list of jobs may neither. */ | |
31 | ||
60918275 LP |
32 | /* Active jobs and names */ |
33 | Hashmap *names; /* name string => Name object n:1 */ | |
34 | Hashmap *jobs; /* job id => Job object 1:1 */ | |
35 | ||
36 | /* Names that need to be loaded */ | |
37 | LIST_HEAD(Meta, load_queue); /* this is actually more a stack than a queue, but uh. */ | |
38 | ||
034c6ed7 LP |
39 | /* Jobs that need to be run */ |
40 | LIST_HEAD(Job, run_queue); /* more a stack than a queue, too */ | |
41 | ||
e5b5ae50 LP |
42 | /* Jobs to be added */ |
43 | Hashmap *transaction_jobs; /* Name object => Job object list 1:1 */ | |
44 | JobDependency *transaction_anchor; | |
223dabab LP |
45 | |
46 | bool dispatching_load_queue:1; | |
034c6ed7 | 47 | bool dispatching_run_queue:1; |
5cb5a6ff | 48 | |
9152c765 LP |
49 | Hashmap *watch_pids; /* pid => Name object n:1 */ |
50 | ||
51 | int epoll_fd; | |
52 | int signal_fd; | |
60918275 LP |
53 | }; |
54 | ||
55 | Manager* manager_new(void); | |
56 | void manager_free(Manager *m); | |
57 | ||
58 | Job *manager_get_job(Manager *m, uint32_t id); | |
59 | Name *manager_get_name(Manager *m, const char *name); | |
60 | ||
61 | int manager_load_name(Manager *m, const char *name, Name **_ret); | |
e5b5ae50 | 62 | int manager_add_job(Manager *m, JobType type, Name *name, JobMode mode, bool force, Job **_ret); |
60918275 | 63 | |
cea8e32e LP |
64 | void manager_dump_names(Manager *s, FILE *f, const char *prefix); |
65 | void manager_dump_jobs(Manager *s, FILE *f, const char *prefix); | |
a66d02c3 | 66 | |
302d0040 | 67 | void manager_transaction_unlink_job(Manager *m, Job *j); |
e5b5ae50 | 68 | |
7fad411c LP |
69 | void manager_clear_jobs(Manager *m); |
70 | ||
034c6ed7 | 71 | void manager_dispatch_run_queue(Manager *m); |
9152c765 | 72 | int manager_loop(Manager *m); |
83c60c9f | 73 | |
60918275 | 74 | #endif |