blob: 76924074ade928de2ff1cd42553f5b10230a09fb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
.. _module-pw_async_basic:
================
pw_async_basic
================
This module includes basic implementations of pw_async's Dispatcher and
FakeDispatcher.
---
API
---
.. doxygenclass:: pw::async::BasicDispatcher
:members:
-----
Usage
-----
First, set the following GN variables:
.. code-block::
pw_async_TASK_BACKEND="$dir_pw_async_basic:task"
pw_async_FAKE_DISPATCHER_BACKEND="$dir_pw_async_basic:fake_dispatcher"
Next, create a target that depends on ``//pw_async_basic:dispatcher``:
.. code-block::
pw_executable("hello_world") {
sources = [ "hello_world.cc" ]
deps = [
"//pw_async_basic:dispatcher",
]
}
Next, construct and use a ``BasicDispatcher``.
.. code-block:: cpp
#include "pw_async_basic/dispatcher.h"
void DelayedPrint(pw::async::Dispatcher& dispatcher) {
dispatcher.PostAfter([](auto&){
printf("hello world\n");
}, 5s);
}
int main() {
pw::async::BasicDispatcher dispatcher;
DelayedPrint(dispatcher);
dispatcher.RunFor(10s);
return 0;
}
-----------
Size Report
-----------
.. include:: docs_size_report
|