]> git.ipfire.org Git - people/ms/systemd.git/blame - job.h
make sure impact of transactions is minimized
[people/ms/systemd.git] / job.h
CommitLineData
60918275
LP
1/*-*- Mode: C; c-basic-offset: 8 -*-*/
2
3#ifndef foojobhfoo
4#define foojobhfoo
5
6#include <stdbool.h>
7#include <inttypes.h>
8
9typedef struct Job Job;
e5b5ae50 10typedef struct JobDependency JobDependency;
60918275
LP
11typedef enum JobType JobType;
12typedef enum JobMode JobMode;
e5b5ae50 13typedef enum JobState JobState;
60918275
LP
14
15#include "manager.h"
16#include "name.h"
17#include "hashmap.h"
18#include "list.h"
19
20enum JobType {
21 JOB_START,
22 JOB_STOP,
23 JOB_VERIFY_STARTED,
e5b5ae50
LP
24 JOB_RELOAD, /* reload if running */
25 JOB_RELOAD_OR_START, /* reload if running, start if not running */
26 JOB_RESTART, /* stop if running, then start unconditionally */
27 JOB_TRY_RESTART, /* stop and start if running */
28 _JOB_TYPE_MAX,
29 _JOB_TYPE_INVALID = -1
60918275
LP
30};
31
e5b5ae50 32enum JobState {
60918275
LP
33 JOB_WAITING,
34 JOB_RUNNING,
35 JOB_DONE,
36 _JOB_STATE_MAX
e5b5ae50 37};
60918275
LP
38
39enum JobMode {
40 JOB_FAIL,
41 JOB_REPLACE,
42 _JOB_MODE_MAX
43};
44
e5b5ae50
LP
45struct JobDependency {
46 /* Encodes that the 'subject' job needs the 'object' job in
47 * some way. This structure is used only while building a transaction. */
48 Job *subject;
49 Job *object;
50
51 bool matters;
52
53 /* Linked list for the subjects, resp objects */
54 JobDependency *subject_prev, *subject_next;
55 JobDependency *object_prev, *object_next;
56};
57
60918275
LP
58struct Job {
59 Manager *manager;
60 uint32_t id;
61
e5b5ae50
LP
62 Name *name;
63
60918275
LP
64 JobType type;
65 JobState state;
60918275
LP
66
67 bool linked:1;
e5b5ae50
LP
68 bool matters_to_anchor:1;
69
70 /* These fields are used only while building a transaction */
71 Job *transaction_next, *transaction_prev;
72
73 JobDependency *subject_list;
74 JobDependency *object_list;
75
76 /* used for graph algs as a "I have been here" marker */
77 Job* marker;
78 unsigned generation;
60918275
LP
79};
80
81Job* job_new(Manager *m, JobType type, Name *name);
60918275 82void job_free(Job *job);
ceed3570 83void job_dump(Job *j, FILE*f, const char *prefix);
60918275 84
e5b5ae50
LP
85JobDependency* job_dependency_new(Job *subject, Job *object, bool matters);
86void job_dependency_free(JobDependency *l);
87void job_dependency_delete(Job *subject, Job *object, bool *matters);
88
89bool job_is_anchor(Job *j);
90
91int job_merge(Job *j, Job *other);
92
1ffba6fe
LP
93const char* job_type_to_string(JobType t);
94int job_type_merge(JobType *a, JobType b);
95bool job_type_mergeable(JobType a, JobType b);
96bool job_type_is_superset(JobType a, JobType b);
e094e853 97bool job_type_is_conflicting(JobType a, JobType b);
1ffba6fe 98
60918275 99#endif