aboutsummaryrefslogtreecommitdiffstats
path: root/doc/examples/nonblocking/README
blob: ef4990cd43ada5600c4a8cf73cf9771bd04fcadf (plain) (blame)
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
API usage example

This example shows how to use bus_poll instead of bus_read,
and how to do non-blocking polling and non-blocking writing.



First of, run make to build this example.

To start the example run ./init.
When you are done run ./cleanup.

Running instances of ./poll will check every second
if there is a new inbound message. Between these checks
./write will wait for all ./poll:s to receive the message.
This means that ./write blocks while ./poll sleeps.
If two or more instances of ./write is started at
approximately the same time, only one will continue to
write a message on the bus, the others will fail.

./poll will stop if the message "stop" is broadcasted.

./poll, ./init and ./cleanup are run without any
additional arguments. ./write is run with the message
as the second argument.