-
Notifications
You must be signed in to change notification settings - Fork 178
Move the EventFlags example to an external repo #803
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,39 +4,10 @@ | |
|
||
The EventFlags class provides a mechanism for setting and waiting for specific conditions. It provides a generic way of notifying other threads about conditions or events. You can think of each instance of the EventFlags class as an event channel. There are 31 different flags available for each event. | ||
|
||
### EventFlag class reference | ||
### EventFlags class reference | ||
|
||
[](http://os-doc-builder.test.mbed.com/docs/development/mbed-os-api-doxy/classrtos_1_1_event_flags.html) | ||
|
||
### EventFlags example | ||
|
||
Below is an example of EventFlags usage, where one thread is generating events every 1s, and the second thread is waiting for the events and executing some action. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Query: Is this deleted description still relevant? If so, could we please keep it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since I've slightly updated the example code, the description should also be updated. Do you prefer to have it here, or should I rather edit the new README file https://github.com/ARMmbed/mbed-os-examples-docs_only/blob/master/EventFlags/README.md ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the example is self-explanatory enough that it doesn't need setup, feel free to edit it only in the README file. If the example needs some context, please edit it here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good question 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. README updated in a new PR ARMmbed/mbed-os-examples-docs_only#8 since the last one got merged already. |
||
|
||
<span class="images"></span> | ||
|
||
``` | ||
#include "mbed.h" | ||
|
||
EventFlags event; | ||
|
||
void worker_f() | ||
{ | ||
while (true) { | ||
event.wait_all(0x1); | ||
|
||
printf("Got signal!\r\n"); | ||
} | ||
} | ||
|
||
int main() | ||
{ | ||
Thread worker; | ||
|
||
worker.start(callback(worker_f)); | ||
|
||
while (true) { | ||
wait(1); | ||
event.set(0x1); | ||
} | ||
} | ||
``` | ||
[](https://github.com/ARMmbed/mbed-os-examples-docs_only/blob/master/EventFlags/main.cpp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch 👍