1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
4 typedef struct Timer Timer
;
5 typedef struct ActivationDetailsTimer ActivationDetailsTimer
;
7 #include "calendarspec.h"
10 typedef enum TimerBase
{
18 _TIMER_BASE_INVALID
= -EINVAL
,
21 typedef struct TimerValue
{
25 usec_t value
; /* only for monotonic events */
26 CalendarSpec
*calendar_spec
; /* only for calendar events */
29 LIST_FIELDS(struct TimerValue
, value
);
32 typedef enum TimerResult
{
34 TIMER_FAILURE_RESOURCES
,
35 TIMER_FAILURE_START_LIMIT_HIT
,
37 _TIMER_RESULT_INVALID
= -EINVAL
,
46 LIST_HEAD(TimerValue
, values
);
47 usec_t next_elapse_realtime
;
48 usec_t next_elapse_monotonic_or_boottime
;
49 dual_timestamp last_trigger
;
51 TimerState state
, deserialized_state
;
53 sd_event_source
*monotonic_event_source
;
54 sd_event_source
*realtime_event_source
;
60 bool remain_after_elapse
;
62 bool on_timezone_change
;
63 bool fixed_random_delay
;
68 struct ActivationDetailsTimer
{
69 ActivationDetails meta
;
70 dual_timestamp last_trigger
;
73 #define TIMER_MONOTONIC_CLOCK(t) ((t)->wake_system ? CLOCK_BOOTTIME_ALARM : CLOCK_MONOTONIC)
75 void timer_free_values(Timer
*t
);
77 extern const UnitVTable timer_vtable
;
78 extern const ActivationDetailsVTable activation_details_timer_vtable
;
80 const char *timer_base_to_string(TimerBase i
) _const_
;
81 TimerBase
timer_base_from_string(const char *s
) _pure_
;
83 const char* timer_result_to_string(TimerResult i
) _const_
;
84 TimerResult
timer_result_from_string(const char *s
) _pure_
;
86 DEFINE_CAST(TIMER
, Timer
);
87 DEFINE_ACTIVATION_DETAILS_CAST(ACTIVATION_DETAILS_TIMER
, ActivationDetailsTimer
, TIMER
);