Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
EventQueue.h
- Committer:
- Christopher Haster
- Date:
- 2016-04-20
- Revision:
- 2:11cda6bead99
- Parent:
- 1:2202c19570e5
- Child:
- 10:62767e708bb6
File content as of revision 2:11cda6bead99:
/* EventQueue
*
* Flexible queue for managing events
*/
#ifndef EVENT_QUEUE_H
#define EVENT_QUEUE_H
#include "mbed.h"
/** Flexible queue for managing events
*/
class EventQueue {
public:
/** Create an event queue
*/
EventQueue();
/** Dispatch pending events
* @param ms Time to wait for events in milliseconds,
* 0 indicates to return immediately if no events are pending
*/
void dispatch(int ms=-1);
/** Get current tick of the event queue
* @return Number of milliseconds since the queue was instantiated,
* this count intentionally overflows to 0 after 2^32-1
*/
unsigned get_tick();
private:
struct event {
struct event *volatile next;
unsigned target;
bool registered;
int delay;
int period;
void (*callback)(void *);
void *data;
};
void event_register(struct event *event, int ms);
void event_unregister(struct event *event);
void tick();
void wakeup();
struct event *volatile _queue;
unsigned _tick;
mbed::Ticker _ticker;
mbed::Timer _timer;
template <typename F>
friend class Event;
};
#endif