diff options
author | kib <kib@FreeBSD.org> | 2012-11-20 15:33:48 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2012-11-20 15:33:48 +0000 |
commit | f0eb44bc70263f6f188d8f07d367628d2efb6716 (patch) | |
tree | 444d06ff6a3b2b0eef2bda7713393644d7a67fe5 /sys/kern/subr_taskqueue.c | |
parent | f31aa350da4c1b4c93b747fa9a4044dd1a6eb349 (diff) | |
download | FreeBSD-src-f0eb44bc70263f6f188d8f07d367628d2efb6716.zip FreeBSD-src-f0eb44bc70263f6f188d8f07d367628d2efb6716.tar.gz |
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
Diffstat (limited to 'sys/kern/subr_taskqueue.c')
-rw-r--r-- | sys/kern/subr_taskqueue.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/sys/kern/subr_taskqueue.c b/sys/kern/subr_taskqueue.c index 90c6ffc..3bf62f9 100644 --- a/sys/kern/subr_taskqueue.c +++ b/sys/kern/subr_taskqueue.c @@ -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); |