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