Centralized thread cancellation in processor_t
This ensures that no threads are active when plugins and the rest of the daemon are unloaded. callback_job_t was simplified a lot in the process as its main functionality is now contained in processor_t. The parent-child relationships were abandoned as these were only needed to simplify job cancellation.
This commit is contained in:
@@ -67,11 +67,6 @@ struct private_scheduler_t {
|
||||
*/
|
||||
scheduler_t public;
|
||||
|
||||
/**
|
||||
* Job which queues scheduled jobs to the processor.
|
||||
*/
|
||||
callback_job_t *job;
|
||||
|
||||
/**
|
||||
* The heap in which the events are stored.
|
||||
*/
|
||||
@@ -309,7 +304,6 @@ METHOD(scheduler_t, destroy, void,
|
||||
private_scheduler_t *this)
|
||||
{
|
||||
event_t *event;
|
||||
this->job->cancel(this->job);
|
||||
this->condvar->destroy(this->condvar);
|
||||
this->mutex->destroy(this->mutex);
|
||||
while ((event = remove_event(this)) != NULL)
|
||||
@@ -326,6 +320,7 @@ METHOD(scheduler_t, destroy, void,
|
||||
scheduler_t * scheduler_create()
|
||||
{
|
||||
private_scheduler_t *this;
|
||||
callback_job_t *job;
|
||||
|
||||
INIT(this,
|
||||
.public = {
|
||||
@@ -342,9 +337,9 @@ scheduler_t * scheduler_create()
|
||||
|
||||
this->heap = (event_t**)calloc(this->heap_size + 1, sizeof(event_t*));
|
||||
|
||||
this->job = callback_job_create_with_prio((callback_job_cb_t)schedule,
|
||||
this, NULL, NULL, JOB_PRIO_CRITICAL);
|
||||
lib->processor->queue_job(lib->processor, (job_t*)this->job);
|
||||
job = callback_job_create_with_prio((callback_job_cb_t)schedule, this,
|
||||
NULL, return_false, JOB_PRIO_CRITICAL);
|
||||
lib->processor->queue_job(lib->processor, (job_t*)job);
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user