1
- ## The mbed-events library ##
1
+ ## The ` mbed-events ` library ##
2
2
3
- The mbed-events library provides a flexible queue for scheduling events.
3
+ The ` mbed-events ` library provides a flexible queue for scheduling events.
4
4
5
5
``` cpp
6
6
#include " mbed_events.h"
@@ -20,18 +20,18 @@ int main() {
20
20
}
21
21
```
22
22
23
- The mbed-events library can be used as a normal event loop, or it can be
24
- backgrounded on a single hardware timer or even another event loop. It is
25
- both thread and irq safe, and provides functions for easily composing
23
+ You can use the ` mbed-events library ` as a normal event loop, or you can
24
+ background it on a single hardware timer or even another event loop. It is
25
+ both thread and IRQ safe and provides functions for easily composing
26
26
independent event queues.
27
27
28
- The mbed-events library can act as a drop-in scheduler, provide synchronization
29
- between multiple threads, or just act as a mechanism for moving events out of
28
+ The ` mbed-events ` library can act as a drop-in scheduler, provide synchronization
29
+ between multiple threads or act as a mechanism for moving events out of
30
30
interrupt contexts.
31
31
32
32
### Usage ###
33
33
34
- The core of the mbed-events library is the [ EventQueue] ( EventQueue.h ) class,
34
+ The core of the ` mbed-events library ` is the [ EventQueue] ( EventQueue.h ) class,
35
35
which represents a single event queue. The ` EventQueue::dispatch ` function
36
36
runs the queue, providing the context for executing events.
37
37
@@ -53,8 +53,8 @@ queue.dispatch();
53
53
```
54
54
55
55
The EventQueue class provides several call functions for posting events
56
- to the underlying event queue. The call functions are thread and irq safe,
57
- don't need the underlying loop to be running, and provide an easy mechanism
56
+ to the underlying event queue. The call functions are thread and IRQ safe,
57
+ don't need the underlying loop to be running and provide a mechanism
58
58
for moving events out of interrupt contexts.
59
59
60
60
``` cpp
@@ -73,8 +73,8 @@ queue.call_every(2000, doit_every_two_seconds);
73
73
queue.call_every(400, printf, "called every 0.4 seconds\n");
74
74
```
75
75
76
- The call functions return an id that uniquely represents the event in the
77
- the event queue. This id can be passed to ` EventQueue::cancel ` to cancel
76
+ The call functions return an ID that uniquely represents the event in the
77
+ the event queue. You can pass this ID to ` EventQueue::cancel ` to cancel
78
78
an in-flight event.
79
79
80
80
``` cpp
@@ -92,9 +92,9 @@ if (id) {
92
92
queue.cancel(id);
93
93
```
94
94
95
- For a more fine-grain control of event dispatch, the ` Event ` class can be
96
- manually instantiated and configured . An ` Event ` represents an event as
97
- a C++ style function object and can be directly passed to other APIs that
95
+ For a more detailed control of event dispatch, you can manually instantiate
96
+ and configure the ` Event ` class . An ` Event ` represents an event as
97
+ a C++ style function object, and you can directly pass it to other APIs that
98
98
expect a callback.
99
99
100
100
``` cpp
@@ -126,7 +126,7 @@ queue.dispatch();
126
126
127
127
Event queues easily align with module boundaries, where internal state can
128
128
be implicitly synchronized through event dispatch. Multiple modules can
129
- use independent event queues, but still be composed through the
129
+ use independent event queues but still be composed through the
130
130
`EventQueue::chain` function.
131
131
132
132
``` cpp
0 commit comments