Shared event example. Instead of creating special thread user can use shared event queue and dispatch the global event queue from main thread.

Fork of Shared_Events_1 by mbed_example

Files at this revision

API Documentation at this revision

Comitter:
deepikabhavnani
Date:
Mon Dec 18 16:58:28 2017 +0000
Parent:
0:7c7d5b625e59
Commit message:
Shared event example: running the shared queue from main

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed_app.json Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Mon Dec 18 16:50:19 2017 +0000
+++ b/main.cpp	Mon Dec 18 16:58:28 2017 +0000
@@ -21,6 +21,8 @@
     printf("Starting in context %p\r\n", Thread::gettid());
     // The 'rise' handler will execute in IRQ context
     sw.rise(rise_handler);
-    // The 'fall' handler will execute in the context of the shared queue thread
+    // The 'fall' handler will execute in the context of the shared queue (actually the main thread)
     sw.fall(queue->event(fall_handler));
+    // Setup complete, so we now dispatch the shared queue from main
+    queue->dispatch_forever();
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed_app.json	Mon Dec 18 16:58:28 2017 +0000
@@ -0,0 +1,7 @@
+{
+    "target_overrides": {
+        "*": {
+            "events.shared-dispatch-from-application": true
+        }
+     }
+}
\ No newline at end of file