C/C++ API Reference
Loading...
Searching...
No Matches
owned_task.h
1// Copyright 2025 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_async2/task.h"
17#include "pw_log/tokenized_args.h"
18
20
21namespace pw::async2 {
22
31class OwnedTask : public Task {
32 protected:
33 explicit constexpr OwnedTask(log::Token name = kDefaultName)
34 : Task(name, Task::OwnedTag{}) {}
35
36 private:
37 friend Dispatcher;
38
39 // Deregister is private on OwnedTask because it's unsafe to call after the
40 // task is posted. The dispatcher could delete the task at any time, so posted
41 // tasks should not be accessed outside of the dispatcher.
42 using Task::Deregister;
43
48 void Destroy() { DoDestroy(); }
49
57 virtual void DoDestroy() = 0;
58};
59
60} // namespace pw::async2
Definition: dispatcher.h:53
Definition: owned_task.h:31
Definition: task.h:62
virtual void DoDestroy()=0