Pigweed
 
Loading...
Searching...
No Matches
dispatcher_native.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_async2/dispatcher_base.h"
17#include "pw_sync/thread_notification.h"
18
19namespace pw::async2::backend {
20
21// Windows GCC doesn't realize the nonvirtual destructor is protected and that
22// the class is final.
24PW_MODIFY_DIAGNOSTIC_GCC(ignored, "-Wnon-virtual-dtor");
25
26// Implementor's note:
27//
28// This class defines the "basic" backend for the ``Dispatcher`` facade.
29//
30// All public and private methods here are necessary when implementing a
31// ``Dispatcher`` backend. The private methods are invoked via the
32// ``DispatcherImpl` via CRTP.
33//
34// The ``Dispatcher`` type here is publicly exposed as
35// ``pw::async2::Dispatcher``. Any additional backend-specific public methods
36// should include a ``Native`` prefix to indicate that they are
37// platform-specific extensions and are not portable to other ``pw::async2``
38// backends.
40 public:
41 NativeDispatcher() = default;
42
43 // NOTE: there are no public methods here because the public interface of
44 // ``Dispatcher`` is defined in ``DispatcherImpl``.
45 //
46 // Any additional public methods added here (or in another ``Dispatcher``
47 // backend) would be backend-specific and should be clearly marked with a
48 // ``...Native`` suffix.
49 private:
50 friend class ::pw::async2::Dispatcher;
51
52 void DoWake() final { notify_.release(); }
53 Poll<> DoRunUntilStalled(Dispatcher&, Task* task);
54 void DoRunToCompletion(Dispatcher&, Task* task);
55
57};
58
60
61} // namespace pw::async2::backend
A single-threaded cooperatively-scheduled runtime for async tasks.
Definition: dispatcher.h:42
Definition: dispatcher_base.h:406
Definition: poll.h:54
Definition: dispatcher_base.h:158
Definition: dispatcher_native.h:39
void DoWake() final
Definition: dispatcher_native.h:52
Definition: thread_notification.h:36
#define PW_MODIFY_DIAGNOSTICS_POP()
Definition: compiler.h:191
#define PW_MODIFY_DIAGNOSTIC_GCC(kind, option)
Definition: compiler.h:208
#define PW_MODIFY_DIAGNOSTICS_PUSH()
Definition: compiler.h:186