platform for developing on SQFMI's Watchy
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

34 lines
762 B

#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);
}