Note! This project has moved to github.com/armmbed/mbed-events
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.
Diff: EventQueue.h
- Revision:
- 1:2202c19570e5
- Parent:
- 0:b1b901ae3696
- Child:
- 2:11cda6bead99
--- a/EventQueue.h Wed Apr 20 11:43:51 2016 -0500 +++ b/EventQueue.h Wed Apr 20 12:40:18 2016 -0500 @@ -11,14 +11,14 @@ class EventQueue { public: /** Dispatch pending events - * @param milli Time to wait for events in milliseconds, + * @param ms Time to wait for events in milliseconds, * 0 indicates to return immediately if no events are pending */ - void dispatch(unsigned milli=-1); + void dispatch(int ms=-1); private: struct event { - struct event *next; + struct event *volatile next; void (*callback)(void *); void *data; }; @@ -29,7 +29,7 @@ template <typename F> friend class Event; - struct event *_queue; + struct event *volatile _queue; };