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.
Diff: EventQueue.cpp
- Revision:
- 1:2202c19570e5
- Parent:
- 0:b1b901ae3696
- Child:
- 2:11cda6bead99
--- a/EventQueue.cpp Wed Apr 20 11:43:51 2016 -0500 +++ b/EventQueue.cpp Wed Apr 20 12:40:18 2016 -0500 @@ -4,11 +4,11 @@ static void wakeup() {} -void EventQueue::dispatch(unsigned milli) { +void EventQueue::dispatch(int ms) { mbed::Timer timer; mbed::Timeout timeout; timer.start(); - timeout.attach_us(wakeup, milli * 1000); + timeout.attach_us(wakeup, ms * 1000); while (true) { while (_queue) { @@ -16,7 +16,7 @@ _queue = _queue->next; } - if ((unsigned)timer.read_ms() > milli) { + if (ms >= 0 && timer.read_ms() >= ms) { break; } @@ -26,7 +26,7 @@ void EventQueue::event_register(struct event *event) { __disable_irq(); - for (struct event **p = &_queue;; p = &(*p)->next) { + for (struct event *volatile *p = &_queue;; p = &(*p)->next) { if (!*p) { event->next = 0; *p = event; @@ -40,7 +40,7 @@ void EventQueue::event_unregister(struct event *event) { __disable_irq(); - for (struct event **p = &_queue; *p; p = &(*p)->next) { + for (struct event *volatile *p = &_queue; *p; p = &(*p)->next) { if (*p == event) { *p = event->next; break;