C/C++ API Reference
Loading...
Searching...
No Matches
heap_dispatcher.h
1// Copyright 2023 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_async/function_dispatcher.h"
17
18namespace pw::async {
19
21
25class HeapDispatcher final : public FunctionDispatcher {
26 public:
27 HeapDispatcher(Dispatcher& dispatcher) : dispatcher_(dispatcher) {}
28 ~HeapDispatcher() override = default;
29
30 // FunctionDispatcher overrides:
32 chrono::SystemClock::time_point time) override;
33
34 // Dispatcher overrides:
35 inline void PostAt(Task& task,
36 chrono::SystemClock::time_point time) override {
37 return dispatcher_.PostAt(task, time);
38 }
39 inline bool Cancel(Task& task) override { return dispatcher_.Cancel(task); }
40
41 // VirtualSystemClock overrides:
42 inline chrono::SystemClock::time_point now() override {
43 return dispatcher_.now();
44 }
45
46 private:
47 Dispatcher& dispatcher_;
48};
49
50} // namespace pw::async
Definition: status.h:86
Definition: dispatcher.h:48
Definition: function_dispatcher.h:29
Definition: heap_dispatcher.h:25
Definition: task.h:33
virtual bool Cancel(Task &task)=0
Status PostAt(TaskFunction &&task_func, chrono::SystemClock::time_point time) override
Post dispatcher owned |task_func| function to be run at |time|.
chrono::SystemClock::time_point now() override
Returns the current time.
Definition: heap_dispatcher.h:42
Function< void(Context &, Status)> TaskFunction
Definition: task_function.h:39
virtual void PostAt(Task &task, chrono::SystemClock::time_point time)=0
bool Cancel(Task &task) override
Definition: heap_dispatcher.h:39
void PostAt(Task &task, chrono::SystemClock::time_point time) override
Definition: heap_dispatcher.h:35
virtual SystemClock::time_point now()=0
Returns the current time.
(Deprecated) Async library
Definition: context.h:19