1.1 Using a timer synchronously
See http://www.boost.org/doc/libs/1_55_0/doc/html/boost_asio/tutorial/tuttimer1.html
In Felix our async I/O service is called Faio, for Felix Asynchronous I/O. It provides two core features, a timer service and TCP/IP via sockets. To use the timer we need to include the Faio library.
include "std/io/faio";
Now we need to make an alarm clock. Since the library is packaged
into a class namespace called Faio
which is not open by default,
we need an explicit qualifier.
Recall also that {#p} means the same as {p()} but is terser. So here is our clock:
var clock = #Faio::mk_alarm_clock;
Now we want to go to sleep for 5 seconds. We have to give Faoi
a clock to work with. But lets print a message first so we can
observe the delay.
println$ "The Big Bang!"; Faio::sleep (clock, 5.0);
After the delay, we print a message.
println$ "Hello world!";
We expect to see this with some delays:
The Big Bang! Hello world!
Test with
build/release/host/bin/flx --test=build/release src/web/tut/async_01.html