1 /* SPDX-License-Identifier: LGPL-2.1+ */
5 This file is part of systemd.
7 Copyright 2010 Lennart Poettering
10 typedef struct Timer Timer
;
12 #include "calendarspec.h"
14 typedef enum TimerBase
{
22 _TIMER_BASE_INVALID
= -1
25 typedef struct TimerValue
{
29 usec_t value
; /* only for monotonic events */
30 CalendarSpec
*calendar_spec
; /* only for calendar events */
33 LIST_FIELDS(struct TimerValue
, value
);
36 typedef enum TimerResult
{
38 TIMER_FAILURE_RESOURCES
,
39 TIMER_FAILURE_START_LIMIT_HIT
,
41 _TIMER_RESULT_INVALID
= -1
50 LIST_HEAD(TimerValue
, values
);
51 usec_t next_elapse_realtime
;
52 usec_t next_elapse_monotonic_or_boottime
;
53 dual_timestamp last_trigger
;
55 TimerState state
, deserialized_state
;
57 sd_event_source
*monotonic_event_source
;
58 sd_event_source
*realtime_event_source
;
64 bool remain_after_elapse
;
69 #define TIMER_MONOTONIC_CLOCK(t) ((t)->wake_system && clock_boottime_supported() ? CLOCK_BOOTTIME_ALARM : CLOCK_MONOTONIC)
71 void timer_free_values(Timer
*t
);
73 extern const UnitVTable timer_vtable
;
75 const char *timer_base_to_string(TimerBase i
) _const_
;
76 TimerBase
timer_base_from_string(const char *s
) _pure_
;
78 const char* timer_result_to_string(TimerResult i
) _const_
;
79 TimerResult
timer_result_from_string(const char *s
) _pure_
;