]> git.ipfire.org Git - thirdparty/systemd.git/blob - manager.h
implement transaction engine
[thirdparty/systemd.git] / manager.h
1 /*-*- Mode: C; c-basic-offset: 8 -*-*/
2
3 #ifndef foomanagerhfoo
4 #define foomanagerhfoo
5
6 #include <stdbool.h>
7 #include <inttypes.h>
8 #include <stdio.h>
9
10 typedef struct Manager Manager;
11
12 #include "name.h"
13 #include "job.h"
14 #include "hashmap.h"
15 #include "list.h"
16 #include "set.h"
17
18 struct Manager {
19 uint32_t current_job_id;
20
21 /* Note that the set of names we know of is allowed to be
22 * incosistent. However the subset of it that is loaded may
23 * not, and the list of jobs may neither. */
24
25 /* Active jobs and names */
26 Hashmap *names; /* name string => Name object n:1 */
27 Hashmap *jobs; /* job id => Job object 1:1 */
28
29 /* Names that need to be loaded */
30 LIST_HEAD(Meta, load_queue); /* this is actually more a stack than a queue, but uh. */
31
32 /* Jobs to be added */
33 Hashmap *transaction_jobs; /* Name object => Job object list 1:1 */
34 JobDependency *transaction_anchor;
35
36 bool dispatching_load_queue:1;
37 };
38
39 Manager* manager_new(void);
40 void manager_free(Manager *m);
41
42 Job *manager_get_job(Manager *m, uint32_t id);
43 Name *manager_get_name(Manager *m, const char *name);
44
45 int manager_load_name(Manager *m, const char *name, Name **_ret);
46 int manager_add_job(Manager *m, JobType type, Name *name, JobMode mode, bool force, Job **_ret);
47
48 void manager_dump_names(Manager *s, FILE *f);
49 void manager_dump_jobs(Manager *s, FILE *f);
50
51 void manager_transaction_delete_job(Manager *m, Job *j);
52
53 #endif