Full Program
Dependencies: TCPEthernetEverything
eventqueue.cpp
00001 /* 00002 * (c) Copyright 2012 EVRYTHNG Ltd London / Zurich 00003 * www.evrythng.com 00004 * 00005 * --- DISCLAIMER --- 00006 * 00007 * EVRYTHNG provides this source code "as is" and without warranty of any kind, 00008 * and hereby disclaims all express or implied warranties, including without 00009 * limitation warranties of merchantability, fitness for a particular purpose, 00010 * performance, accuracy, reliability, and non-infringement. 00011 * 00012 * Author: Michel Yerly 00013 * 00014 */ 00015 #include "mbed.h" 00016 #include "eventqueue.h" 00017 #include <time.h> 00018 00019 #include "util.h" 00020 00021 void EventQueue::put(int64_t time, EventType type) 00022 { 00023 Event event; 00024 event.time = time; 00025 event.type = type; 00026 queue.push(event); 00027 } 00028 00029 EventType EventQueue::waitNext(int64_t currentTime) 00030 { 00031 Event event = queue.top(); 00032 queue.pop(); 00033 int64_t w = event.time - currentTime; 00034 if (w > 0) wait_ms(w); 00035 return event.type; 00036 } 00037 00038 bool EventQueue::empty() 00039 { 00040 return queue.empty(); 00041 } 00042 00043 int EventQueue::size() 00044 { 00045 return queue.size(); 00046 }
Generated on Mon Aug 15 2022 13:54:08 by 1.7.2