1 /* SPDX-License-Identifier: LGPL-2.1+ */
4 typedef struct Timer Timer
;
6 #include "calendarspec.h"
9 typedef enum TimerBase
{
17 _TIMER_BASE_INVALID
= -1
20 typedef struct TimerValue
{
24 usec_t value
; /* only for monotonic events */
25 CalendarSpec
*calendar_spec
; /* only for calendar events */
28 LIST_FIELDS(struct TimerValue
, value
);
31 typedef enum TimerResult
{
33 TIMER_FAILURE_RESOURCES
,
34 TIMER_FAILURE_START_LIMIT_HIT
,
36 _TIMER_RESULT_INVALID
= -1
45 LIST_HEAD(TimerValue
, values
);
46 usec_t next_elapse_realtime
;
47 usec_t next_elapse_monotonic_or_boottime
;
48 dual_timestamp last_trigger
;
50 TimerState state
, deserialized_state
;
52 sd_event_source
*monotonic_event_source
;
53 sd_event_source
*realtime_event_source
;
59 bool remain_after_elapse
;
64 #define TIMER_MONOTONIC_CLOCK(t) ((t)->wake_system && clock_boottime_supported() ? CLOCK_BOOTTIME_ALARM : CLOCK_MONOTONIC)
66 void timer_free_values(Timer
*t
);
68 extern const UnitVTable timer_vtable
;
70 const char *timer_base_to_string(TimerBase i
) _const_
;
71 TimerBase
timer_base_from_string(const char *s
) _pure_
;
73 const char* timer_result_to_string(TimerResult i
) _const_
;
74 TimerResult
timer_result_from_string(const char *s
) _pure_
;
76 DEFINE_CAST(TIMER
, Timer
);