Skip to content

Edit README.md #9311

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 10, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions events/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## The mbed-events library ##
## The `mbed-events` library ##

The mbed-events library provides a flexible queue for scheduling events.
The `mbed-events` library provides a flexible queue for scheduling events.

``` cpp
#include "mbed_events.h"
Expand All @@ -20,18 +20,18 @@ int main() {
}
```

The mbed-events library can be used as a normal event loop, or it can be
backgrounded on a single hardware timer or even another event loop. It is
both thread and irq safe, and provides functions for easily composing
You can use the `mbed-events library` as a normal event loop, or you can
background it on a single hardware timer or even another event loop. It is
both thread and IRQ safe and provides functions for easily composing
independent event queues.

The mbed-events library can act as a drop-in scheduler, provide synchronization
between multiple threads, or just act as a mechanism for moving events out of
The `mbed-events` library can act as a drop-in scheduler, provide synchronization
between multiple threads or act as a mechanism for moving events out of
interrupt contexts.

### Usage ###

The core of the mbed-events library is the [EventQueue](EventQueue.h) class,
The core of the `mbed-events library` is the [EventQueue](EventQueue.h) class,
which represents a single event queue. The `EventQueue::dispatch` function
runs the queue, providing the context for executing events.

Expand All @@ -53,8 +53,8 @@ queue.dispatch();
```

The EventQueue class provides several call functions for posting events
to the underlying event queue. The call functions are thread and irq safe,
don't need the underlying loop to be running, and provide an easy mechanism
to the underlying event queue. The call functions are thread and IRQ safe,
don't need the underlying loop to be running and provide a mechanism
for moving events out of interrupt contexts.

``` cpp
Expand All @@ -73,8 +73,8 @@ queue.call_every(2000, doit_every_two_seconds);
queue.call_every(400, printf, "called every 0.4 seconds\n");
```

The call functions return an id that uniquely represents the event in the
the event queue. This id can be passed to `EventQueue::cancel` to cancel
The call functions return an ID that uniquely represents the event in the
the event queue. You can pass this ID to `EventQueue::cancel` to cancel
an in-flight event.

``` cpp
Expand All @@ -92,9 +92,9 @@ if (id) {
queue.cancel(id);
```

For a more fine-grain control of event dispatch, the `Event` class can be
manually instantiated and configured. An `Event` represents an event as
a C++ style function object and can be directly passed to other APIs that
For a more detailed control of event dispatch, you can manually instantiate
and configure the `Event` class. An `Event` represents an event as
a C++ style function object, and you can directly pass it to other APIs that
expect a callback.

``` cpp
Expand Down Expand Up @@ -126,7 +126,7 @@ queue.dispatch();

Event queues easily align with module boundaries, where internal state can
be implicitly synchronized through event dispatch. Multiple modules can
use independent event queues, but still be composed through the
use independent event queues but still be composed through the
`EventQueue::chain` function.

``` cpp
Expand Down