]> git.proxmox.com Git - systemd.git/blob - src/core/timer.h
Merge tag 'upstream/229'
[systemd.git] / src / core / timer.h
1 #pragma once
2
3 /***
4 This file is part of systemd.
5
6 Copyright 2010 Lennart Poettering
7
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or
11 (at your option) any later version.
12
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
20 ***/
21
22 typedef struct Timer Timer;
23
24 #include "calendarspec.h"
25
26 typedef enum TimerBase {
27 TIMER_ACTIVE,
28 TIMER_BOOT,
29 TIMER_STARTUP,
30 TIMER_UNIT_ACTIVE,
31 TIMER_UNIT_INACTIVE,
32 TIMER_CALENDAR,
33 _TIMER_BASE_MAX,
34 _TIMER_BASE_INVALID = -1
35 } TimerBase;
36
37 typedef struct TimerValue {
38 TimerBase base;
39 bool disabled;
40
41 usec_t value; /* only for monotonic events */
42 CalendarSpec *calendar_spec; /* only for calendar events */
43 usec_t next_elapse;
44
45 LIST_FIELDS(struct TimerValue, value);
46 } TimerValue;
47
48 typedef enum TimerResult {
49 TIMER_SUCCESS,
50 TIMER_FAILURE_RESOURCES,
51 _TIMER_RESULT_MAX,
52 _TIMER_RESULT_INVALID = -1
53 } TimerResult;
54
55 struct Timer {
56 Unit meta;
57
58 usec_t accuracy_usec;
59 usec_t random_usec;
60
61 LIST_HEAD(TimerValue, values);
62 usec_t next_elapse_realtime;
63 usec_t next_elapse_monotonic_or_boottime;
64 dual_timestamp last_trigger;
65
66 TimerState state, deserialized_state;
67
68 sd_event_source *monotonic_event_source;
69 sd_event_source *realtime_event_source;
70
71 TimerResult result;
72
73 bool persistent;
74 bool wake_system;
75 bool remain_after_elapse;
76
77 char *stamp_path;
78 };
79
80 void timer_free_values(Timer *t);
81
82 extern const UnitVTable timer_vtable;
83
84 const char *timer_base_to_string(TimerBase i) _const_;
85 TimerBase timer_base_from_string(const char *s) _pure_;
86
87 const char* timer_result_to_string(TimerResult i) _const_;
88 TimerResult timer_result_from_string(const char *s) _pure_;