COSA
An Object-Oriented Platform for Arduino Programming
Event.cpp
Go to the documentation of this file.
1 
21 #include "Cosa/Event.hh"
22 #include "Cosa/Watchdog.hh"
23 
25 
26 bool
27 Event::service(uint32_t ms)
28 {
29  uint32_t start = Watchdog::millis();
30  Event event;
31  while (!queue.dequeue(&event)) {
32  if ((ms == 0L) || (Watchdog::since(start) < ms))
33  yield();
34  else
35  return (false);
36  }
37  event.dispatch();
38  return (true);
39 }
40 
bool dequeue(T *data)
Definition: Queue.hh:145
static uint32_t millis()
Definition: Watchdog.hh:51
static Queue< Event, QUEUE_MAX > queue
Definition: Event.hh:204
static uint32_t since(uint32_t start)
Definition: Watchdog.hh:108
Definition: Queue.hh:35
void(* yield)()
Definition: Event.hh:39
static bool service(uint32_t ms=0L)
Definition: Event.cpp:27