summaryrefslogtreecommitdiff
path: root/job.h
blob: 0fc6fec4625316865faf1d43fd71359563b8a9e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*-*- Mode: C; c-basic-offset: 8 -*-*/

#ifndef foojobhfoo
#define foojobhfoo

#include <stdbool.h>
#include <inttypes.h>

typedef struct Job Job;
typedef enum JobType JobType;
typedef enum JobMode JobMode;

#include "manager.h"
#include "name.h"
#include "hashmap.h"
#include "list.h"

enum JobType {
        JOB_START,
        JOB_STOP,
        JOB_VERIFY_STARTED,
        JOB_RELOAD,
        JOB_RESTART,
        JOB_TRY_RESTART, /* restart if running */
        JOB_RESTART_FINISH, /* 2nd part of a restart, i.e. the actual starting */
        _JOB_TYPE_MAX
};

typedef enum JobState {
        JOB_WAITING,
        JOB_RUNNING,
        JOB_DONE,
        _JOB_STATE_MAX
} JobState;

enum JobMode {
        JOB_FAIL,
        JOB_REPLACE,
        _JOB_MODE_MAX
};

struct Job {
        Manager *manager;
        uint32_t id;

        JobType type;
        JobState state;
        Name *name;

        bool linked:1;
};

Job* job_new(Manager *m, JobType type, Name *name);
int job_link(Job *job);
void job_free(Job *job);
void job_dump(Job *j, FILE*f);

#endif