1 /*-*- Mode: C; c-basic-offset: 8 -*-*/
10 typedef struct Manager Manager
;
11 typedef enum ManagerEventType ManagerEventType
;
19 enum ManagerEventType
{
26 uint32_t current_job_id
;
28 /* Note that the set of units 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. */
32 /* Active jobs and units */
33 Hashmap
*units
; /* name string => Unit object n:1 */
34 Hashmap
*jobs
; /* job id => Job object 1:1 */
36 /* Units that need to be loaded */
37 LIST_HEAD(Meta
, load_queue
); /* this is actually more a stack than a queue, but uh. */
39 /* Jobs that need to be run */
40 LIST_HEAD(Job
, run_queue
); /* more a stack than a queue, too */
42 /* Jobs to be added */
43 Hashmap
*transaction_jobs
; /* Unit object => Job object list 1:1 */
44 JobDependency
*transaction_anchor
;
46 bool dispatching_load_queue
:1;
47 bool dispatching_run_queue
:1;
49 Hashmap
*watch_pids
; /* pid => Unit object n:1 */
55 Manager
* manager_new(void);
56 void manager_free(Manager
*m
);
58 Job
*manager_get_job(Manager
*m
, uint32_t id
);
59 Unit
*manager_get_unit(Manager
*m
, const char *name
);
61 int manager_load_unit(Manager
*m
, const char *path_or_name
, Unit
**_ret
);
62 int manager_add_job(Manager
*m
, JobType type
, Unit
*unit
, JobMode mode
, bool force
, Job
**_ret
);
64 void manager_dump_units(Manager
*s
, FILE *f
, const char *prefix
);
65 void manager_dump_jobs(Manager
*s
, FILE *f
, const char *prefix
);
67 void manager_transaction_unlink_job(Manager
*m
, Job
*j
);
69 void manager_clear_jobs(Manager
*m
);
71 void manager_dispatch_run_queue(Manager
*m
);
72 int manager_loop(Manager
*m
);