Pigweed
 
Loading...
Searching...
No Matches
system_timer.h
1// Copyright 2021 The Pigweed Authors
2//
3// Licensed under the Apache License, Version 2.0 (the "License"); you may not
4// use this file except in compliance with the License. You may obtain a copy of
5// the License at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12// License for the specific language governing permissions and limitations under
13// the License.
14#pragma once
15
16#include "pw_chrono/system_clock.h"
17#include "pw_chrono_backend/system_timer_native.h"
18#include "pw_function/function.h"
19
20namespace pw::chrono {
21
36 public:
37 using native_handle_type = backend::NativeSystemTimerHandle;
38
53 Function<void(SystemClock::time_point expired_deadline)>;
54
60
67
68 SystemTimer(const SystemTimer&) = delete;
69 SystemTimer(SystemTimer&&) = delete;
70 SystemTimer& operator=(const SystemTimer&) = delete;
71 SystemTimer& operator=(SystemTimer&&) = delete;
72
83
93 void InvokeAt(SystemClock::time_point timestamp);
94
104 void Cancel();
105
106 native_handle_type native_handle();
107
108 private:
110 backend::NativeSystemTimer native_type_;
111};
112
113} // namespace pw::chrono
114
115#include "pw_chrono_backend/system_timer_inline.h"
Definition: system_timer.h:35
SystemTimer(ExpiryCallback &&callback)
void InvokeAt(SystemClock::time_point timestamp)
Function< void(SystemClock::time_point expired_deadline)> ExpiryCallback
Definition: system_timer.h:53
void InvokeAfter(SystemClock::duration delay)
fit::function_impl< function_internal::config::kInlineCallableSize, !function_internal::config::kEnableDynamicAllocation, FunctionType, PW_FUNCTION_DEFAULT_ALLOCATOR_TYPE > Function
Definition: function.h:74
std::chrono::duration< rep, period > duration
Alias for durations representable with this clock.
Definition: system_clock.h:86