1 /* SPDX-License-Identifier: LGPL-2.1+ */
5 Copyright 2010 Lennart Poettering
8 typedef struct Timer Timer
;
10 #include "calendarspec.h"
13 typedef enum TimerBase
{
21 _TIMER_BASE_INVALID
= -1
24 typedef struct TimerValue
{
28 usec_t value
; /* only for monotonic events */
29 CalendarSpec
*calendar_spec
; /* only for calendar events */
32 LIST_FIELDS(struct TimerValue
, value
);
35 typedef enum TimerResult
{
37 TIMER_FAILURE_RESOURCES
,
38 TIMER_FAILURE_START_LIMIT_HIT
,
40 _TIMER_RESULT_INVALID
= -1
49 LIST_HEAD(TimerValue
, values
);
50 usec_t next_elapse_realtime
;
51 usec_t next_elapse_monotonic_or_boottime
;
52 dual_timestamp last_trigger
;
54 TimerState state
, deserialized_state
;
56 sd_event_source
*monotonic_event_source
;
57 sd_event_source
*realtime_event_source
;
63 bool remain_after_elapse
;
68 #define TIMER_MONOTONIC_CLOCK(t) ((t)->wake_system && clock_boottime_supported() ? CLOCK_BOOTTIME_ALARM : CLOCK_MONOTONIC)
70 void timer_free_values(Timer
*t
);
72 extern const UnitVTable timer_vtable
;
74 const char *timer_base_to_string(TimerBase i
) _const_
;
75 TimerBase
timer_base_from_string(const char *s
) _pure_
;
77 const char* timer_result_to_string(TimerResult i
) _const_
;
78 TimerResult
timer_result_from_string(const char *s
) _pure_
;
80 DEFINE_CAST(TIMER
, Timer
);