1 /*-*- Mode: C; c-basic-offset: 8 -*-*/
10 typedef struct Manager Manager
;
11 typedef enum WatchType WatchType
;
12 typedef struct Watch Watch
;
33 typedef enum SpecialUnit
{
34 SPECIAL_SYSLOG_SERVICE
,
36 SPECIAL_LOGGER_SOCKET
,
37 SPECIAL_CTRL_ALT_DEL_TARGET
,
38 SPECIAL_KBREQUEST_TARGET
,
43 uint32_t current_job_id
;
45 /* Note that the set of units we know of is allowed to be
46 * incosistent. However the subset of it that is loaded may
47 * not, and the list of jobs may neither. */
49 /* Active jobs and units */
50 Hashmap
*units
; /* name string => Unit object n:1 */
51 Hashmap
*jobs
; /* job id => Job object 1:1 */
53 /* Units that need to be loaded */
54 LIST_HEAD(Meta
, load_queue
); /* this is actually more a stack than a queue, but uh. */
56 /* Jobs that need to be run */
57 LIST_HEAD(Job
, run_queue
); /* more a stack than a queue, too */
59 /* Jobs to be added */
60 Hashmap
*transaction_jobs
; /* Unit object => Job object list 1:1 */
61 JobDependency
*transaction_anchor
;
63 bool dispatching_load_queue
:1;
64 bool dispatching_run_queue
:1;
66 Hashmap
*watch_pids
; /* pid => Unit object n:1 */
72 Unit
*special_units
[_SPECIAL_UNIT_MAX
]; /* some special units */
77 Manager
* manager_new(void);
78 void manager_free(Manager
*m
);
80 Job
*manager_get_job(Manager
*m
, uint32_t id
);
81 Unit
*manager_get_unit(Manager
*m
, const char *name
);
83 int manager_load_unit(Manager
*m
, const char *path_or_name
, Unit
**_ret
);
84 int manager_add_job(Manager
*m
, JobType type
, Unit
*unit
, JobMode mode
, bool force
, Job
**_ret
);
86 void manager_dump_units(Manager
*s
, FILE *f
, const char *prefix
);
87 void manager_dump_jobs(Manager
*s
, FILE *f
, const char *prefix
);
89 void manager_transaction_unlink_job(Manager
*m
, Job
*j
);
91 void manager_clear_jobs(Manager
*m
);
93 void manager_dispatch_run_queue(Manager
*m
);
94 int manager_loop(Manager
*m
);