• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
15load(
16    "//pw_build:pigweed.bzl",
17    "pw_cc_test",
18)
19load("//pw_build:selects.bzl", "TARGET_COMPATIBLE_WITH_HOST_SELECT")
20
21package(default_visibility = ["//visibility:public"])
22
23licenses(["notice"])
24
25cc_library(
26    name = "poll",
27    hdrs = [
28        "public/pw_async2/internal/poll_internal.h",
29        "public/pw_async2/poll.h",
30    ],
31    includes = ["public"],
32    deps = [
33        "//third_party/fuchsia:stdcompat",
34        "@pigweed//pw_polyfill",
35        "@pigweed//pw_string:to_string",
36    ],
37)
38
39pw_cc_test(
40    name = "poll_test",
41    srcs = ["poll_test.cc"],
42    deps = [
43        ":poll",
44        "@pigweed//pw_result",
45    ],
46)
47
48# NOTE: this target should only be used directly by implementors of the
49# `dispatcher` facade.
50cc_library(
51    name = "dispatcher_base",
52    srcs = [
53        "dispatcher_base.cc",
54    ],
55    hdrs = [
56        "public/pw_async2/dispatcher_base.h",
57    ],
58    includes = [
59        "public",
60    ],
61    deps = [
62        ":poll",
63        "@pigweed//pw_assert",
64        "@pigweed//pw_chrono:system_clock",
65        "@pigweed//pw_containers:vector",
66        "@pigweed//pw_sync:interrupt_spin_lock",
67        "@pigweed//pw_sync:lock_annotations",
68        "@pigweed//pw_toolchain:no_destructor",
69    ],
70)
71
72cc_library(
73    name = "dispatcher",
74    hdrs = [
75        "public/pw_async2/dispatcher.h",
76    ],
77    includes = [
78        "public",
79    ],
80    deps = [
81        ":dispatcher_backend",
82        ":dispatcher_base",
83    ],
84)
85
86label_flag(
87    name = "dispatcher_backend",
88    build_setting_default = ":dispatcher_backend_multiplexer",
89)
90
91cc_library(
92    name = "dispatcher_backend_multiplexer",
93    visibility = ["@pigweed//targets:__pkg__"],
94    deps = select({
95        "@platforms//os:linux": ["//pw_async2_epoll:dispatcher"],
96        "//conditions:default": ["//pw_async2_basic:dispatcher"],
97    }),
98)
99
100pw_cc_test(
101    name = "dispatcher_test",
102    srcs = ["dispatcher_test.cc"],
103    deps = [":dispatcher"],
104)
105
106pw_cc_test(
107    name = "dispatcher_thread_test",
108    srcs = ["dispatcher_thread_test.cc"],
109    # TODO: b/343776738 - update to run on all compatible devices
110    target_compatible_with = select(TARGET_COMPATIBLE_WITH_HOST_SELECT),
111    deps = [
112        ":dispatcher",
113        "@pigweed//pw_function",
114        "@pigweed//pw_thread:sleep",
115        "@pigweed//pw_thread:thread",
116    ],
117)
118
119cc_library(
120    name = "pend_func_task",
121    hdrs = [
122        "public/pw_async2/pend_func_task.h",
123    ],
124    includes = [
125        "public",
126    ],
127    deps = [
128        ":dispatcher",
129    ],
130)
131
132pw_cc_test(
133    name = "pend_func_task_test",
134    srcs = ["pend_func_task_test.cc"],
135    deps = [":pend_func_task"],
136)
137
138cc_library(
139    name = "pendable_as_task",
140    hdrs = [
141        "public/pw_async2/pendable_as_task.h",
142    ],
143    includes = [
144        "public",
145    ],
146    deps = [
147        ":dispatcher",
148    ],
149)
150
151pw_cc_test(
152    name = "pendable_as_task_test",
153    srcs = ["pendable_as_task_test.cc"],
154    deps = [":pendable_as_task"],
155)
156
157cc_library(
158    name = "allocate_task",
159    hdrs = [
160        "public/pw_async2/allocate_task.h",
161    ],
162    includes = [
163        "public",
164    ],
165    deps = [
166        ":dispatcher",
167        "//pw_allocator:allocator",
168    ],
169)
170
171pw_cc_test(
172    name = "allocate_task_test",
173    srcs = ["allocate_task_test.cc"],
174    deps = [
175        ":allocate_task",
176        "//pw_allocator:testing",
177    ],
178)
179
180cc_library(
181    name = "coro",
182    hdrs = [
183        "public/pw_async2/coro.h",
184    ],
185    includes = [
186        "public",
187    ],
188    tags = ["requires_cxx_20"],
189    deps = [
190        ":dispatcher",
191        "//pw_allocator:allocator",
192    ],
193)
194
195pw_cc_test(
196    name = "coro_test",
197    srcs = ["coro_test.cc"],
198    tags = ["requires_cxx_20"],
199    deps = [
200        ":coro",
201        ":dispatcher",
202        "//pw_allocator:null_allocator",
203        "//pw_allocator:testing",
204    ],
205)
206