Commit b07f8da9 authored by Bob Halley's avatar Bob Halley
Browse files

eliminate timer_shutdown; add purging option to timer_reset

parent 258c9ab8
......@@ -47,7 +47,8 @@ tick(task_t task, task_event_t event)
interval.seconds = 4;
interval.nanoseconds = 0;
printf("*** resetting ti3 ***\n");
INSIST(timer_reset(ti3, timer_type_once, expires, interval)
INSIST(timer_reset(ti3, timer_type_once, expires, interval,
TRUE)
== ISC_R_SUCCESS);
}
......
......@@ -54,6 +54,7 @@
***/
#include <isc/result.h>
#include <isc/boolean.h>
#include <isc/time.h>
#include <isc/task.h>
#include <isc/event.h>
......@@ -146,10 +147,12 @@ isc_result
timer_reset(timer_t timer,
timer_type_t type,
os_time_t expires,
os_time_t interval);
os_time_t interval,
boolean_t purge);
/*
* Change the timer's type, expires, and interval values to the given
* values.
* values. If 'purge' is TRUE, any pending events from this timer
* are purged from its task's event queue.
*
* Requires:
*
......@@ -171,26 +174,6 @@ timer_reset(timer_t timer,
* Unexpected error
*/
isc_result
timer_shutdown(timer_t timer);
/*
* Make 'timer' inactive, and purge any pending timer events for this timer
* in the timer's task's event queue.
*
* Requires:
*
* 'timer' is a valid timer
*
* Ensures:
*
* No events for this timer remain in its task's event queue.
*
* Returns:
*
* Success
* Unexpected error
*/
isc_result
timer_touch(timer_t timer);
/*
......
......@@ -284,15 +284,16 @@ timer_create(timer_manager_t manager, timer_type_t type,
isc_result
timer_reset(timer_t timer, timer_type_t type,
os_time_t expires, os_time_t interval)
os_time_t expires, os_time_t interval, boolean_t purge)
{
os_time_t now;
timer_manager_t manager;
isc_result result;
/*
* Change the timer's type, expires, and interval values to the
* given values.
* Change the timer's type, expires, and interval values to the given
* values. If 'purge' is TRUE, any pending events from this timer
* are purged from its task's event queue.
*/
REQUIRE(VALID_TIMER(timer));
......@@ -316,6 +317,8 @@ timer_reset(timer_t timer, timer_type_t type,
LOCK(&manager->lock);
LOCK(&timer->lock);
if (purge)
task_purge_events(timer->task, timer, TASK_EVENT_ANYEVENT);
timer->type = type;
timer->expires = expires;
timer->interval = interval;
......@@ -333,31 +336,6 @@ timer_reset(timer_t timer, timer_type_t type,
return (result);
}
isc_result
timer_shutdown(timer_t timer) {
timer_manager_t manager;
/*
* Make 'timer' inactive, and purge any pending timer events for
* this timer in the timer's task's event queue.
*/
REQUIRE(VALID_TIMER(timer));
manager = timer->manager;
REQUIRE(VALID_MANAGER(manager));
LOCK(&manager->lock);
LOCK(&timer->lock);
task_purge_events(timer->task, timer, TASK_EVENT_ANYEVENT);
deschedule(timer);
UNLOCK(&timer->lock);
UNLOCK(&manager->lock);
return (ISC_R_SUCCESS);
}
isc_result
timer_touch(timer_t timer) {
isc_result result;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment