#include <config/xf-config.h>

#if (USE_XF_IDF_STM32_EVENT_QUEUE_CLASS != 0)

#include <cassert>
#include "eventqueue.h"

// TODO done: Implement code for XFEventQueue class

XFEventQueue::XFEventQueue(){

}

XFEventQueue::~XFEventQueue(){

}

bool XFEventQueue::empty() const {
	return queue_.empty();
}

bool XFEventQueue::push(const XFEvent *pEvent, bool fromISR) {
	(void) fromISR;
	mutex_.lock();
	queue_.push(pEvent);
	mutex_.unlock();
	return true;
}

const XFEvent* XFEventQueue::front() {
	return queue_.front();
}

void XFEventQueue::pop() {
	mutex_.lock();
	queue_.pop();
	mutex_.unlock();
}


bool XFEventQueue::pend() {
    // Method cannot be used in an IDF! Waiting within
    // this method would block the whole XF
    return false;
}

#endif // USE_XF_IDF_STM32_EVENT_QUEUE_CLASS
