Note! This project has moved to github.com/armmbed/mbed-events

Dependents:   SimpleHTTPExample

This repository has been superceded

This project has moved to mbed-events

Composable event loops combine the cheap synchronicity of event loops with the composability of preempted threads.

Two modular event queue classes are provided:

  • EventLoop - for loops coupled with a c++ managed thread
  • EventQueue - for manually managed event queues

The Event class takes advantage of the extensibility of FuncPtr to allow an event to be passed through APIs as a normal function.

More information on composable event loops.

Revision:
16:ff5d48fcce1b
Parent:
15:92d7c0b8a0f5
Child:
17:6d564266850e
--- a/EventQueue.h	Tue May 10 09:23:27 2016 -0500
+++ b/EventQueue.h	Mon Apr 18 09:47:21 2016 -0500
@@ -21,7 +21,10 @@
      */
     EventQueue(unsigned event_count=32,
                unsigned event_context=0);
-    virtual ~EventQueue();
+
+    /** Clean up event queue
+     */
+    ~EventQueue();
 
     /** Dispatch pending events
      *  @param ms       Time to wait for events in milliseconds,
@@ -35,6 +38,12 @@
      */
     unsigned get_tick();
 
+    /** Determine if tick has been passed
+     *  @param          Tick to check
+     *  @param          True if tick has been passed
+     */
+    bool past_tick(unsigned tick);
+
 private:
     struct event {
         struct event *volatile next;
@@ -67,15 +76,11 @@
     }
 
     void tick();
-    void wakeup();
-    void exit(volatile bool *exit);
 
-    unsigned _event_count;
     unsigned _event_context;
-
+    void *_mem;
+    struct event *volatile _free;
     struct event *volatile _queue;
-    struct event *volatile _free;
-    void *_mem;
 
     unsigned _tick;
     mbed::Ticker _ticker;