diff options
Diffstat (limited to 'src/libstrongswan/processing/jobs/callback_job.c')
-rw-r--r-- | src/libstrongswan/processing/jobs/callback_job.c | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/src/libstrongswan/processing/jobs/callback_job.c b/src/libstrongswan/processing/jobs/callback_job.c index 0043a9cdb..13f22e69c 100644 --- a/src/libstrongswan/processing/jobs/callback_job.c +++ b/src/libstrongswan/processing/jobs/callback_job.c @@ -62,7 +62,7 @@ struct private_callback_job_t { mutex_t *mutex; /** - * list of asociated child jobs + * list of associated child jobs */ linked_list_t *children; @@ -88,6 +88,11 @@ struct private_callback_job_t { * without risking that it gets freed too early during destruction. */ sem_t *terminated; + + /** + * Priority of this job + */ + job_priority_t prio; }; /** @@ -227,12 +232,18 @@ METHOD(job_t, execute, void, thread_cleanup_pop(cleanup); } +METHOD(job_t, get_priority, job_priority_t, + private_callback_job_t *this) +{ + return this->prio; +} + /* * Described in header. */ -callback_job_t *callback_job_create(callback_job_cb_t cb, void *data, - callback_job_cleanup_t cleanup, - callback_job_t *parent) +callback_job_t *callback_job_create_with_prio(callback_job_cb_t cb, void *data, + callback_job_cleanup_t cleanup, callback_job_t *parent, + job_priority_t prio) { private_callback_job_t *this; @@ -240,6 +251,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, @@ -251,6 +263,7 @@ callback_job_t *callback_job_create(callback_job_cb_t cb, void *data, .children = linked_list_create(), .parent = (private_callback_job_t*)parent, .destroyable = condvar_create(CONDVAR_TYPE_DEFAULT), + .prio = prio, ); /* register us at parent */ @@ -264,3 +277,13 @@ callback_job_t *callback_job_create(callback_job_cb_t cb, void *data, return &this->public; } +/* + * Described in header. + */ +callback_job_t *callback_job_create(callback_job_cb_t cb, void *data, + callback_job_cleanup_t cleanup, + callback_job_t *parent) +{ + return callback_job_create_with_prio(cb, data, cleanup, parent, + JOB_PRIO_MEDIUM); +} |