2010-01-23 07:52:57 +07:00
|
|
|
/*-*- Mode: C; c-basic-offset: 8 -*-*/
|
|
|
|
|
2010-01-27 03:39:06 +07:00
|
|
|
#include "unit.h"
|
2010-01-23 07:52:57 +07:00
|
|
|
#include "timer.h"
|
|
|
|
|
2010-01-27 03:39:06 +07:00
|
|
|
static void timer_done(Unit *u) {
|
|
|
|
Timer *t = TIMER(u);
|
2010-01-26 10:18:44 +07:00
|
|
|
|
|
|
|
assert(t);
|
|
|
|
}
|
|
|
|
|
2010-01-27 03:39:06 +07:00
|
|
|
static UnitActiveState timer_active_state(Unit *u) {
|
2010-01-23 07:52:57 +07:00
|
|
|
|
2010-01-27 03:39:06 +07:00
|
|
|
static const UnitActiveState table[_TIMER_STATE_MAX] = {
|
|
|
|
[TIMER_DEAD] = UNIT_INACTIVE,
|
|
|
|
[TIMER_WAITING] = UNIT_ACTIVE,
|
|
|
|
[TIMER_RUNNING] = UNIT_ACTIVE
|
2010-01-23 07:52:57 +07:00
|
|
|
};
|
|
|
|
|
2010-01-27 03:39:06 +07:00
|
|
|
return table[TIMER(u)->state];
|
2010-01-23 07:52:57 +07:00
|
|
|
}
|
|
|
|
|
2010-01-27 03:39:06 +07:00
|
|
|
const UnitVTable timer_vtable = {
|
2010-01-23 07:52:57 +07:00
|
|
|
.suffix = ".timer",
|
|
|
|
|
2010-01-27 03:39:06 +07:00
|
|
|
.init = unit_load_fragment_and_dropin,
|
2010-01-26 10:18:44 +07:00
|
|
|
.done = timer_done,
|
2010-01-23 07:52:57 +07:00
|
|
|
|
2010-01-26 10:18:44 +07:00
|
|
|
.active_state = timer_active_state
|
2010-01-23 07:52:57 +07:00
|
|
|
};
|