C/C++ API Reference
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
23
38 public:
39 using native_handle_type = backend::NativeSystemTimerHandle;
40
55 Function<void(SystemClock::time_point expired_deadline)>;
56
62
69
70 SystemTimer(const SystemTimer&) = delete;
71 SystemTimer(SystemTimer&&) = delete;
72 SystemTimer& operator=(const SystemTimer&) = delete;
73 SystemTimer& operator=(SystemTimer&&) = delete;
74
85
95 void InvokeAt(SystemClock::time_point timestamp);
96
106 void Cancel();
107
108 native_handle_type native_handle();
109
110 private:
112 backend::NativeSystemTimer native_type_;
113};
114
115} // namespace pw::chrono
116
117#include "pw_chrono_backend/system_timer_inline.h"
Definition: system_timer.h:37
SystemTimer(ExpiryCallback &&callback)
void InvokeAt(SystemClock::time_point timestamp)
Function< void(SystemClock::time_point expired_deadline)> ExpiryCallback
Definition: system_timer.h:55
void InvokeAfter(SystemClock::duration delay)
std::chrono::duration< rep, period > duration
Alias for durations representable with this clock.
Definition: system_clock.h:90
fit::function_impl< function_internal::config::kInlineCallableSize, !function_internal::config::kEnableDynamicAllocation, FunctionType, PW_FUNCTION_DEFAULT_ALLOCATOR_TYPE > Function
Definition: function.h:73
Portable std::chrono library for embedded.
Definition: simulated_system_clock.h:22