#include "watchos.h" #include "EventListener.h" EventListener::EventListener() { m_event_queue = new Queue(); } bool EventListener::hasEvent() { return !m_event_queue->isEmpty(); } Event* EventListener::getEvent() { kernel_handle_t handle = m_event_queue->peek(); // Fetch and immediately release, the event queue still holds the reference. Event* e = watchos::event(handle); return e; } void EventListener::popEvent() { // Once we're done with the event, remove from the event queue and release // the reference it holds. kernel_handle_t handle = m_event_queue->pop(); watchos::release(handle); } void EventListener::pushEvent(kernel_handle_t handle) { watchos::reference(handle); m_event_queue->push(handle); }