1 /*-*- Mode: C; c-basic-offset: 8 -*-*/
10 typedef struct Manager Manager;
11 typedef enum WatchType WatchType;
12 typedef struct Watch Watch;
34 uint32_t current_job_id;
36 /* Note that the set of units we know of is allowed to be
37 * incosistent. However the subset of it that is loaded may
38 * not, and the list of jobs may neither. */
40 /* Active jobs and units */
41 Hashmap *units; /* name string => Unit object n:1 */
42 Hashmap *jobs; /* job id => Job object 1:1 */
44 /* Units that need to be loaded */
45 LIST_HEAD(Meta, load_queue); /* this is actually more a stack than a queue, but uh. */
47 /* Jobs that need to be run */
48 LIST_HEAD(Job, run_queue); /* more a stack than a queue, too */
50 /* Jobs to be added */
51 Hashmap *transaction_jobs; /* Unit object => Job object list 1:1 */
52 JobDependency *transaction_anchor;
54 bool dispatching_load_queue:1;
55 bool dispatching_run_queue:1;
57 Hashmap *watch_pids; /* pid => Unit object n:1 */
64 Manager* manager_new(void);
65 void manager_free(Manager *m);
67 Job *manager_get_job(Manager *m, uint32_t id);
68 Unit *manager_get_unit(Manager *m, const char *name);
70 int manager_load_unit(Manager *m, const char *path_or_name, Unit **_ret);
71 int manager_add_job(Manager *m, JobType type, Unit *unit, JobMode mode, bool force, Job **_ret);
73 void manager_dump_units(Manager *s, FILE *f, const char *prefix);
74 void manager_dump_jobs(Manager *s, FILE *f, const char *prefix);
76 void manager_transaction_unlink_job(Manager *m, Job *j);
78 void manager_clear_jobs(Manager *m);
80 void manager_dispatch_run_queue(Manager *m);
81 int manager_loop(Manager *m);