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:
- 0:b1b901ae3696
- Child:
- 1:2202c19570e5
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/EventQueue.h Wed Apr 20 11:43:51 2016 -0500 @@ -0,0 +1,36 @@ +/* EventQueue + * + * Flexible queue for managing events + */ +#ifndef EVENT_QUEUE_H +#define EVENT_QUEUE_H + + +/** Flexible queue for managing events + */ +class EventQueue { +public: + /** Dispatch pending events + * @param milli Time to wait for events in milliseconds, + * 0 indicates to return immediately if no events are pending + */ + void dispatch(unsigned milli=-1); + +private: + struct event { + struct event *next; + void (*callback)(void *); + void *data; + }; + + void event_register(struct event *event); + void event_unregister(struct event *event); + + template <typename F> + friend class Event; + + struct event *_queue; +}; + + +#endif