pw_async_basic#
Unstable
This module includes basic implementations of pw_async’s Dispatcher and FakeDispatcher.
API#
Moved: pw_async_basic
Usage#
First, set the following GN variables:
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
:
pw_executable("hello_world") {
sources = [ "hello_world.cc" ]
deps = [
"//pw_async_basic:dispatcher",
]
}
Next, construct and use a BasicDispatcher
.
#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#
Label |
Segment |
Delta |
||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Construct a task |
FLASH
|
+208 |