Systemd/job.h

99 lines
2.4 KiB
C
Raw Normal View History

2009-11-18 00:42:52 +01:00
/*-*- Mode: C; c-basic-offset: 8 -*-*/
#ifndef foojobhfoo
#define foojobhfoo
#include <stdbool.h>
#include <inttypes.h>
typedef struct Job Job;
2010-01-20 02:12:51 +01:00
typedef struct JobDependency JobDependency;
2009-11-18 00:42:52 +01:00
typedef enum JobType JobType;
typedef enum JobMode JobMode;
2010-01-20 02:12:51 +01:00
typedef enum JobState JobState;
2009-11-18 00:42:52 +01:00
#include "manager.h"
#include "name.h"
#include "hashmap.h"
#include "list.h"
enum JobType {
JOB_START,
JOB_STOP,
JOB_VERIFY_STARTED,
2010-01-20 02:12:51 +01:00
JOB_RELOAD, /* reload if running */
JOB_RELOAD_OR_START, /* reload if running, start if not running */
JOB_RESTART, /* stop if running, then start unconditionally */
JOB_TRY_RESTART, /* stop and start if running */
_JOB_TYPE_MAX,
_JOB_TYPE_INVALID = -1
2009-11-18 00:42:52 +01:00
};
2010-01-20 02:12:51 +01:00
enum JobState {
2009-11-18 00:42:52 +01:00
JOB_WAITING,
JOB_RUNNING,
JOB_DONE,
_JOB_STATE_MAX
2010-01-20 02:12:51 +01:00
};
2009-11-18 00:42:52 +01:00
enum JobMode {
JOB_FAIL,
JOB_REPLACE,
_JOB_MODE_MAX
};
2010-01-20 02:12:51 +01:00
struct JobDependency {
/* Encodes that the 'subject' job needs the 'object' job in
* some way. This structure is used only while building a transaction. */
Job *subject;
Job *object;
bool matters;
/* Linked list for the subjects, resp objects */
JobDependency *subject_prev, *subject_next;
JobDependency *object_prev, *object_next;
};
2009-11-18 00:42:52 +01:00
struct Job {
Manager *manager;
uint32_t id;
2010-01-20 02:12:51 +01:00
Name *name;
2009-11-18 00:42:52 +01:00
JobType type;
JobState state;
bool linked:1;
2010-01-20 02:12:51 +01:00
bool matters_to_anchor:1;
/* These fields are used only while building a transaction */
Job *transaction_next, *transaction_prev;
JobDependency *subject_list;
JobDependency *object_list;
/* used for graph algs as a "I have been here" marker */
Job* marker;
unsigned generation;
2009-11-18 00:42:52 +01:00
};
Job* job_new(Manager *m, JobType type, Name *name);
void job_free(Job *job);
2010-01-20 02:35:46 +01:00
void job_dump(Job *j, FILE*f, const char *prefix);
2009-11-18 00:42:52 +01:00
2010-01-20 02:12:51 +01:00
JobDependency* job_dependency_new(Job *subject, Job *object, bool matters);
void job_dependency_free(JobDependency *l);
void job_dependency_delete(Job *subject, Job *object, bool *matters);
bool job_is_anchor(Job *j);
int job_merge(Job *j, Job *other);
2010-01-21 00:51:37 +01:00
const char* job_type_to_string(JobType t);
int job_type_merge(JobType *a, JobType b);
bool job_type_mergeable(JobType a, JobType b);
bool job_type_is_superset(JobType a, JobType b);
2009-11-18 00:42:52 +01:00
#endif