]>
Commit | Line | Data |
---|---|---|
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 | ||
9 | typedef struct Job Job; | |
e5b5ae50 | 10 | typedef struct JobDependency JobDependency; |
60918275 LP |
11 | typedef enum JobType JobType; |
12 | typedef enum JobMode JobMode; | |
e5b5ae50 | 13 | typedef enum JobState JobState; |
60918275 LP |
14 | |
15 | #include "manager.h" | |
16 | #include "name.h" | |
17 | #include "hashmap.h" | |
18 | #include "list.h" | |
19 | ||
20 | enum 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 | 32 | enum JobState { |
60918275 LP |
33 | JOB_WAITING, |
34 | JOB_RUNNING, | |
35 | JOB_DONE, | |
36 | _JOB_STATE_MAX | |
e5b5ae50 | 37 | }; |
60918275 LP |
38 | |
39 | enum JobMode { | |
40 | JOB_FAIL, | |
41 | JOB_REPLACE, | |
42 | _JOB_MODE_MAX | |
43 | }; | |
44 | ||
e5b5ae50 LP |
45 | struct 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 |
58 | struct 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 | ||
81 | Job* job_new(Manager *m, JobType type, Name *name); | |
60918275 | 82 | void job_free(Job *job); |
ceed3570 | 83 | void job_dump(Job *j, FILE*f, const char *prefix); |
60918275 | 84 | |
e5b5ae50 LP |
85 | JobDependency* job_dependency_new(Job *subject, Job *object, bool matters); |
86 | void job_dependency_free(JobDependency *l); | |
87 | void job_dependency_delete(Job *subject, Job *object, bool *matters); | |
88 | ||
89 | bool job_is_anchor(Job *j); | |
90 | ||
91 | int job_merge(Job *j, Job *other); | |
92 | ||
1ffba6fe LP |
93 | const char* job_type_to_string(JobType t); |
94 | int job_type_merge(JobType *a, JobType b); | |
95 | bool job_type_mergeable(JobType a, JobType b); | |
96 | bool job_type_is_superset(JobType a, JobType b); | |
e094e853 | 97 | bool job_type_is_conflicting(JobType a, JobType b); |
1ffba6fe | 98 | |
60918275 | 99 | #endif |