Add isc_task_setquantum() and use it for post-init zone loading
Add isc_task_setquantum() function that modifies quantum for the future isc_task_run() invocations. NOTE: The current isc_task_run() caches the task->quantum into a local variable and therefore the current event loop is not affected by any quantum change.
This commit is contained in:
@@ -398,6 +398,15 @@ isc_task_gettag(isc_task_t *task);
|
||||
*\li 'task' is a valid task.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_task_setquantum(isc_task_t *task, unsigned int quantum);
|
||||
/*%<
|
||||
* Set future 'task' quantum to 'quantum'. The current 'task' quantum will be
|
||||
* kept for the current isc_task_run() loop, and will be changed for the next
|
||||
* run. Therefore, the function is save to use from the event callback as it
|
||||
* will not affect the current event loop processing.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_task_beginexclusive(isc_task_t *task);
|
||||
/*%<
|
||||
|
||||
@@ -660,6 +660,16 @@ isc_task_getnetmgr(isc_task_t *task) {
|
||||
return (task->manager->netmgr);
|
||||
}
|
||||
|
||||
void
|
||||
isc_task_setquantum(isc_task_t *task, unsigned int quantum) {
|
||||
REQUIRE(VALID_TASK(task));
|
||||
|
||||
LOCK(&task->lock);
|
||||
task->quantum = (quantum > 0) ? quantum
|
||||
: task->manager->default_quantum;
|
||||
UNLOCK(&task->lock);
|
||||
}
|
||||
|
||||
/***
|
||||
*** Task Manager.
|
||||
***/
|
||||
@@ -670,11 +680,13 @@ task_run(isc_task_t *task) {
|
||||
bool finished = false;
|
||||
isc_event_t *event = NULL;
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
uint32_t quantum;
|
||||
|
||||
REQUIRE(VALID_TASK(task));
|
||||
|
||||
LOCK(&task->lock);
|
||||
/* FIXME */
|
||||
quantum = task->quantum;
|
||||
|
||||
if (task->state != task_state_ready) {
|
||||
goto done;
|
||||
}
|
||||
@@ -747,7 +759,7 @@ task_run(isc_task_t *task) {
|
||||
task->state = task_state_idle;
|
||||
}
|
||||
break;
|
||||
} else if (dispatch_count >= task->quantum) {
|
||||
} else if (dispatch_count >= quantum) {
|
||||
/*
|
||||
* Our quantum has expired, but there is more work to be
|
||||
* done. We'll requeue it to the ready queue later.
|
||||
|
||||
Reference in New Issue
Block a user