Introduce priority classes for jobs
This commit is contained in:
@@ -61,6 +61,12 @@ METHOD(job_t, execute, void,
|
||||
destroy(this);
|
||||
}
|
||||
|
||||
METHOD(job_t, get_priority, job_priority_t,
|
||||
private_acquire_job_t *this)
|
||||
{
|
||||
return JOB_PRIO_MEDIUM;
|
||||
}
|
||||
|
||||
/*
|
||||
* Described in header
|
||||
*/
|
||||
@@ -74,6 +80,7 @@ acquire_job_t *acquire_job_create(u_int32_t reqid,
|
||||
.public = {
|
||||
.job_interface = {
|
||||
.execute = _execute,
|
||||
.get_priority = _get_priority,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -73,6 +73,12 @@ METHOD(job_t, execute, void,
|
||||
destroy(this);
|
||||
}
|
||||
|
||||
METHOD(job_t, get_priority, job_priority_t,
|
||||
private_delete_child_sa_job_t *this)
|
||||
{
|
||||
return JOB_PRIO_MEDIUM;
|
||||
}
|
||||
|
||||
/*
|
||||
* Described in header
|
||||
*/
|
||||
@@ -86,6 +92,7 @@ delete_child_sa_job_t *delete_child_sa_job_create(u_int32_t reqid,
|
||||
.public = {
|
||||
.job_interface = {
|
||||
.execute = _execute,
|
||||
.get_priority = _get_priority,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -92,6 +92,12 @@ METHOD(job_t, execute, void,
|
||||
destroy(this);
|
||||
}
|
||||
|
||||
METHOD(job_t, get_priority, job_priority_t,
|
||||
private_delete_ike_sa_job_t *this)
|
||||
{
|
||||
return JOB_PRIO_MEDIUM;
|
||||
}
|
||||
|
||||
/*
|
||||
* Described in header
|
||||
*/
|
||||
@@ -104,6 +110,7 @@ delete_ike_sa_job_t *delete_ike_sa_job_create(ike_sa_id_t *ike_sa_id,
|
||||
.public = {
|
||||
.job_interface = {
|
||||
.execute = _execute,
|
||||
.get_priority = _get_priority,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -127,6 +127,12 @@ METHOD(job_t, execute, void,
|
||||
}
|
||||
}
|
||||
|
||||
METHOD(job_t, get_priority, job_priority_t,
|
||||
private_inactivity_job_t *this)
|
||||
{
|
||||
return JOB_PRIO_MEDIUM;
|
||||
}
|
||||
|
||||
/**
|
||||
* See header
|
||||
*/
|
||||
@@ -137,8 +143,9 @@ inactivity_job_t *inactivity_job_create(u_int32_t reqid, u_int32_t timeout,
|
||||
|
||||
INIT(this,
|
||||
.public = {
|
||||
.job_interface = {
|
||||
.job_interface = {
|
||||
.execute = _execute,
|
||||
.get_priority = _get_priority,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -223,6 +223,14 @@ static void reinitiate(private_initiate_mediation_job_t *this)
|
||||
destroy(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of job_t.get_priority.
|
||||
*/
|
||||
static job_priority_t get_priority(private_initiate_mediation_job_t *this)
|
||||
{
|
||||
return JOB_PRIO_MEDIUM;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an empty job
|
||||
*/
|
||||
@@ -231,6 +239,7 @@ static private_initiate_mediation_job_t *initiate_mediation_job_create_empty()
|
||||
private_initiate_mediation_job_t *this = malloc_thing(private_initiate_mediation_job_t);
|
||||
|
||||
/* interface functions */
|
||||
this->public.job_interface.get_priority = (job_priority_t (*) (job_t *)) get_priority;
|
||||
this->public.job_interface.destroy = (void (*) (job_t *)) destroy;
|
||||
|
||||
/* private variables */
|
||||
|
||||
@@ -137,6 +137,14 @@ static void execute(private_mediation_job_t *this)
|
||||
destroy(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of job_t.get_priority.
|
||||
*/
|
||||
static job_priority_t get_priority(private_mediation_job_t *this)
|
||||
{
|
||||
return JOB_PRIO_MEDIUM;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an empty mediation job
|
||||
*/
|
||||
@@ -146,6 +154,7 @@ static private_mediation_job_t *mediation_job_create_empty()
|
||||
|
||||
/* interface functions */
|
||||
this->public.job_interface.execute = (void (*) (job_t *)) execute;
|
||||
this->public.job_interface.get_priority = (job_priority_t (*) (job_t *)) get_priority;
|
||||
this->public.job_interface.destroy = (void (*) (job_t *)) destroy;
|
||||
|
||||
/* private variables */
|
||||
|
||||
@@ -120,6 +120,12 @@ METHOD(job_t, execute, void,
|
||||
destroy(this);
|
||||
}
|
||||
|
||||
METHOD(job_t, get_priority, job_priority_t,
|
||||
private_migrate_job_t *this)
|
||||
{
|
||||
return JOB_PRIO_MEDIUM;
|
||||
}
|
||||
|
||||
/*
|
||||
* Described in header
|
||||
*/
|
||||
@@ -135,6 +141,7 @@ migrate_job_t *migrate_job_create(u_int32_t reqid,
|
||||
.public = {
|
||||
.job_interface = {
|
||||
.execute = _execute,
|
||||
.get_priority = _get_priority,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -84,6 +84,12 @@ METHOD(job_t, execute, void,
|
||||
destroy(this);
|
||||
}
|
||||
|
||||
METHOD(job_t, get_priority, job_priority_t,
|
||||
private_process_message_job_t *this)
|
||||
{
|
||||
return JOB_PRIO_MEDIUM;
|
||||
}
|
||||
|
||||
/*
|
||||
* Described in header
|
||||
*/
|
||||
@@ -95,6 +101,7 @@ process_message_job_t *process_message_job_create(message_t *message)
|
||||
.public = {
|
||||
.job_interface = {
|
||||
.execute = _execute,
|
||||
.get_priority = _get_priority,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -71,6 +71,12 @@ METHOD(job_t, execute, void,
|
||||
destroy(this);
|
||||
}
|
||||
|
||||
METHOD(job_t, get_priority, job_priority_t,
|
||||
private_rekey_child_sa_job_t *this)
|
||||
{
|
||||
return JOB_PRIO_MEDIUM;
|
||||
}
|
||||
|
||||
/*
|
||||
* Described in header
|
||||
*/
|
||||
@@ -84,6 +90,7 @@ rekey_child_sa_job_t *rekey_child_sa_job_create(u_int32_t reqid,
|
||||
.public = {
|
||||
.job_interface = {
|
||||
.execute = _execute,
|
||||
.get_priority = _get_priority,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -81,6 +81,12 @@ METHOD(job_t, execute, void,
|
||||
destroy(this);
|
||||
}
|
||||
|
||||
METHOD(job_t, get_priority, job_priority_t,
|
||||
private_rekey_ike_sa_job_t *this)
|
||||
{
|
||||
return JOB_PRIO_MEDIUM;
|
||||
}
|
||||
|
||||
/*
|
||||
* Described in header
|
||||
*/
|
||||
@@ -92,6 +98,7 @@ rekey_ike_sa_job_t *rekey_ike_sa_job_create(ike_sa_id_t *ike_sa_id, bool reauth)
|
||||
.public = {
|
||||
.job_interface = {
|
||||
.execute = _execute,
|
||||
.get_priority = _get_priority,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -70,6 +70,12 @@ METHOD(job_t, execute, void,
|
||||
destroy(this);
|
||||
}
|
||||
|
||||
METHOD(job_t, get_priority, job_priority_t,
|
||||
private_retransmit_job_t *this)
|
||||
{
|
||||
return JOB_PRIO_MEDIUM;
|
||||
}
|
||||
|
||||
/*
|
||||
* Described in header.
|
||||
*/
|
||||
@@ -81,6 +87,7 @@ retransmit_job_t *retransmit_job_create(u_int32_t message_id,ike_sa_id_t *ike_sa
|
||||
.public = {
|
||||
.job_interface = {
|
||||
.execute = _execute,
|
||||
.get_priority = _get_priority,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -85,6 +85,12 @@ METHOD(job_t, execute, void,
|
||||
destroy(this);
|
||||
}
|
||||
|
||||
METHOD(job_t, get_priority, job_priority_t,
|
||||
private_roam_job_t *this)
|
||||
{
|
||||
return JOB_PRIO_MEDIUM;
|
||||
}
|
||||
|
||||
/*
|
||||
* Described in header
|
||||
*/
|
||||
@@ -96,6 +102,7 @@ roam_job_t *roam_job_create(bool address)
|
||||
.public = {
|
||||
.job_interface = {
|
||||
.execute = _execute,
|
||||
.get_priority = _get_priority,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -66,6 +66,12 @@ METHOD(job_t, execute, void,
|
||||
destroy(this);
|
||||
}
|
||||
|
||||
METHOD(job_t, get_priority, job_priority_t,
|
||||
private_send_dpd_job_t *this)
|
||||
{
|
||||
return JOB_PRIO_MEDIUM;
|
||||
}
|
||||
|
||||
/*
|
||||
* Described in header
|
||||
*/
|
||||
@@ -77,6 +83,7 @@ send_dpd_job_t *send_dpd_job_create(ike_sa_id_t *ike_sa_id)
|
||||
.public = {
|
||||
.job_interface = {
|
||||
.execute = _execute,
|
||||
.get_priority = _get_priority,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -60,6 +60,12 @@ METHOD(job_t, execute, void,
|
||||
destroy(this);
|
||||
}
|
||||
|
||||
METHOD(job_t, get_priority, job_priority_t,
|
||||
private_send_keepalive_job_t *this)
|
||||
{
|
||||
return JOB_PRIO_MEDIUM;
|
||||
}
|
||||
|
||||
/*
|
||||
* Described in header
|
||||
*/
|
||||
@@ -71,6 +77,7 @@ send_keepalive_job_t *send_keepalive_job_create(ike_sa_id_t *ike_sa_id)
|
||||
.public = {
|
||||
.job_interface = {
|
||||
.execute = _execute,
|
||||
.get_priority = _get_priority,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -81,6 +81,12 @@ METHOD(job_t, execute, void,
|
||||
destroy(this);
|
||||
}
|
||||
|
||||
METHOD(job_t, get_priority, job_priority_t,
|
||||
private_start_action_job_t *this)
|
||||
{
|
||||
return JOB_PRIO_MEDIUM;
|
||||
}
|
||||
|
||||
/*
|
||||
* Described in header
|
||||
*/
|
||||
@@ -92,6 +98,7 @@ start_action_job_t *start_action_job_create(void)
|
||||
.public = {
|
||||
.job_interface = {
|
||||
.execute = _execute,
|
||||
.get_priority = _get_priority,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -74,6 +74,12 @@ METHOD(job_t, execute, void,
|
||||
destroy(this);
|
||||
}
|
||||
|
||||
METHOD(job_t, get_priority, job_priority_t,
|
||||
private_update_sa_job_t *this)
|
||||
{
|
||||
return JOB_PRIO_MEDIUM;
|
||||
}
|
||||
|
||||
/*
|
||||
* Described in header
|
||||
*/
|
||||
@@ -85,6 +91,7 @@ update_sa_job_t *update_sa_job_create(u_int32_t reqid, host_t *new)
|
||||
.public = {
|
||||
.job_interface = {
|
||||
.execute = _execute,
|
||||
.get_priority = _get_priority,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -40,13 +54,20 @@ 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_ @}*/
|
||||
|
||||
Reference in New Issue
Block a user