aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstrongswan/processing/jobs/job.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstrongswan/processing/jobs/job.h')
-rw-r--r--src/libstrongswan/processing/jobs/job.h53
1 files changed, 48 insertions, 5 deletions
diff --git a/src/libstrongswan/processing/jobs/job.h b/src/libstrongswan/processing/jobs/job.h
index d25cee03e..c3e640065 100644
--- a/src/libstrongswan/processing/jobs/job.h
+++ b/src/libstrongswan/processing/jobs/job.h
@@ -1,4 +1,5 @@
/*
+ * Copyright (C) 2012 Tobias Brunner
* Copyright (C) 2005-2006 Martin Willi
* Copyright (C) 2005 Jan Hutter
* Hochschule fuer Technik Rapperswil
@@ -24,6 +25,8 @@
typedef struct job_t job_t;
typedef enum job_priority_t job_priority_t;
+typedef enum job_requeue_t job_requeue_t;
+typedef enum job_status_t job_status_t;
#include <library.h>
@@ -48,18 +51,56 @@ enum job_priority_t {
extern enum_name_t *job_priority_names;
/**
+ * Job requeueing policy.
+ *
+ * The job requeueing policy defines how a job is handled after it has been
+ * executed.
+ */
+enum job_requeue_t {
+ /** Do not requeue job, destroy it */
+ JOB_REQUEUE_NONE = 0,
+ /** Requeue the job fairly, i.e. it is inserted at the end of the queue */
+ JOB_REQUEUE_FAIR,
+ /** Reexecute the job directly, without the need of requeueing it */
+ JOB_REQUEUE_DIRECT,
+ /** For jobs that rescheduled themselves via scheduler_t */
+ JOB_REQUEUE_SCHEDULED,
+};
+
+/**
+ * Job status
+ */
+enum job_status_t {
+ /** The job is queued and has not yet been executed */
+ JOB_STATUS_QUEUED = 0,
+ /** During execution */
+ JOB_STATUS_EXECUTING,
+ /** If the job got canceled */
+ JOB_STATUS_CANCELED,
+ /** The job was executed successfully */
+ JOB_STATUS_DONE,
+};
+
+/**
* Job interface as it is stored in the job queue.
*/
struct job_t {
/**
+ * Status of this job, is modified exclusively by the processor/scheduler
+ */
+ job_status_t status;
+
+ /**
* Execute a job.
*
* The processing facility executes a job using this method. Jobs are
- * one-shot, they destroy themself after execution, so don't use a job
- * once it has been executed.
+ * one-shot, they are destroyed after execution (depending on the return
+ * value here), so don't use a job once it has been queued.
+ *
+ * @return policy how to requeue the job
*/
- void (*execute) (job_t *this);
+ job_requeue_t (*execute) (job_t *this);
/**
* Get the priority of a job.
@@ -71,8 +112,10 @@ struct job_t {
/**
* Destroy a job.
*
- * Is only called whenever a job was not executed (e.g. due daemon shutdown).
- * After execution, jobs destroy themself.
+ * Is called after a job is executed or got canceled. It is also called
+ * for queued jobs that were never executed.
+ *
+ * Use the status of a job to decide what to do during destruction.
*/
void (*destroy) (job_t *this);
};