diff options
Diffstat (limited to 'src/libstrongswan/processing')
-rw-r--r-- | src/libstrongswan/processing/jobs/callback_job.c | 7 | ||||
-rw-r--r-- | src/libstrongswan/processing/jobs/job.h | 25 |
2 files changed, 30 insertions, 2 deletions
diff --git a/src/libstrongswan/processing/jobs/callback_job.c b/src/libstrongswan/processing/jobs/callback_job.c index 0043a9cdb..2881775b9 100644 --- a/src/libstrongswan/processing/jobs/callback_job.c +++ b/src/libstrongswan/processing/jobs/callback_job.c @@ -227,6 +227,12 @@ METHOD(job_t, execute, void, thread_cleanup_pop(cleanup); } +METHOD(job_t, get_priority, job_priority_t, + private_callback_job_t *this) +{ + return JOB_PRIO_MEDIUM; +} + /* * Described in header. */ @@ -240,6 +246,7 @@ callback_job_t *callback_job_create(callback_job_cb_t cb, void *data, .public = { .job = { .execute = _execute, + .get_priority = _get_priority, .destroy = _destroy, }, .cancel = _cancel, diff --git a/src/libstrongswan/processing/jobs/job.h b/src/libstrongswan/processing/jobs/job.h index 0f1c16ebe..7b2d48705 100644 --- a/src/libstrongswan/processing/jobs/job.h +++ b/src/libstrongswan/processing/jobs/job.h @@ -23,11 +23,25 @@ #define JOB_H_ typedef struct job_t job_t; +typedef enum job_priority_t job_priority_t; #include <library.h> /** - * Job-Interface as it is stored in the job queue. + * Priority classes of jobs + */ +enum job_priority_t { + /** Short jobs executed with highest priority */ + JOB_PRIO_HIGH = 0, + /** Default job priority */ + JOB_PRIO_MEDIUM, + /** Low priority jobs with thread blocking operations */ + JOB_PRIO_LOW, + JOB_PRIO_MAX +}; + +/** + * Job interface as it is stored in the job queue. */ struct job_t { @@ -41,12 +55,19 @@ struct job_t { void (*execute) (job_t *this); /** + * Get the priority of a job. + * + * @return job priority + */ + job_priority_t (*get_priority)(job_t *this); + + /** * Destroy a job. * * Is only called whenever a job was not executed (e.g. due daemon shutdown). * After execution, jobs destroy themself. */ - void (*destroy) (job_t *job); + void (*destroy) (job_t *this); }; #endif /** JOB_H_ @}*/ |