Add a special meaning to the negative ticks argument for
taskqueue_enqueue_timeout(). Do not rearm the callout if it is already armed and the ticks is negative. Otherwise rearm it to fire in abs(ticks) ticks in the future. The intended use is to call taskqueue_enqueue_timeout() for the given timeout_task with the same negative ticks argument. As result, the task is scheduled to execute not further than abs(ticks) ticks in future, and the consequent enqueues are coalesced until the already scheduled task is finished. Reviewed by: rwatson Tested by: Markus Gebert <markus.gebert@hostpoint.ch> MFC after: 2 weeks
This commit is contained in:
parent
f31aa350da
commit
f0eb44bc70
@ -252,9 +252,13 @@ taskqueue_enqueue_timeout(struct taskqueue *queue,
|
||||
} else {
|
||||
queue->tq_callouts++;
|
||||
timeout_task->f |= DT_CALLOUT_ARMED;
|
||||
if (ticks < 0)
|
||||
ticks = -ticks; /* Ignore overflow. */
|
||||
}
|
||||
if (ticks > 0) {
|
||||
callout_reset(&timeout_task->c, ticks,
|
||||
taskqueue_timeout_func, timeout_task);
|
||||
}
|
||||
callout_reset(&timeout_task->c, ticks, taskqueue_timeout_func,
|
||||
timeout_task);
|
||||
}
|
||||
TQ_UNLOCK(queue);
|
||||
return (res);
|
||||
|
Loading…
Reference in New Issue
Block a user