polsih bracket

This commit is contained in:
Rémi Heredero 2023-10-05 11:46:23 +02:00
parent 6bfe6ee059
commit 25f77289d7
3 changed files with 18 additions and 35 deletions

View File

@ -7,23 +7,19 @@
#include <QMutexLocker> #include <QMutexLocker>
#include "eventqueue.h" #include "eventqueue.h"
XFEventQueue::XFEventQueue() XFEventQueue::XFEventQueue() {
{
} }
XFEventQueue::~XFEventQueue() XFEventQueue::~XFEventQueue() {
{
newEvents_.wakeAll(); newEvents_.wakeAll();
} }
bool XFEventQueue::empty() const bool XFEventQueue::empty() const {
{
return queue_.isEmpty(); return queue_.isEmpty();
} }
bool XFEventQueue::push(const XFEvent * pEvent, bool fromISR) bool XFEventQueue::push(const XFEvent * pEvent, bool fromISR) {
{ (void)fromISR; // Just for don't have the warning
(void)fromISR;
QMutexLocker locker(&mutex_); QMutexLocker locker(&mutex_);
queue_.enqueue(pEvent); queue_.enqueue(pEvent);
// Tell waiting thread(s) there is again an event present // Tell waiting thread(s) there is again an event present
@ -31,19 +27,16 @@ bool XFEventQueue::push(const XFEvent * pEvent, bool fromISR)
return true; return true;
} }
const XFEvent * XFEventQueue::front() const XFEvent * XFEventQueue::front() {
{
return queue_.front(); return queue_.front();
} }
void XFEventQueue::pop() void XFEventQueue::pop() {
{
QMutexLocker locker(&mutex_); QMutexLocker locker(&mutex_);
queue_.dequeue(); queue_.dequeue();
} }
bool XFEventQueue::pend() bool XFEventQueue::pend() {
{
QMutexLocker locker(&mutex_); QMutexLocker locker(&mutex_);
// Wait for new events. Mutex needs to be in lock-state // Wait for new events. Mutex needs to be in lock-state
// prior to call wait()! // prior to call wait()!

View File

@ -10,26 +10,21 @@
*/ */
StateMachine01::StateMachine01(int repeatInterval, string text) StateMachine01::StateMachine01(int repeatInterval, string text)
: repeatInterval_(repeatInterval), : repeatInterval_(repeatInterval),
text_(text) text_(text) {
{
currentState_ = STATE_INITIAL; currentState_ = STATE_INITIAL;
} }
StateMachine01::~StateMachine01() StateMachine01::~StateMachine01() {
{
} }
XFEventStatus StateMachine01::processEvent() XFEventStatus StateMachine01::processEvent() {
{
eEventStatus eventStatus = XFEventStatus::Unknown; eEventStatus eventStatus = XFEventStatus::Unknown;
switch (currentState_) switch (currentState_) {
{
case STATE_INITIAL: case STATE_INITIAL:
{ {
if (getCurrentEvent()->getEventType() == XFEvent::Initial) if (getCurrentEvent()->getEventType() == XFEvent::Initial) {
{
GEN(XFDefaultTransition()); GEN(XFDefaultTransition());
currentState_ = STATE_SAY_HELLO; currentState_ = STATE_SAY_HELLO;

View File

@ -2,31 +2,26 @@
#include "trace/trace.h" #include "trace/trace.h"
#include "testfactory01.h" #include "testfactory01.h"
void Factory_initialize() void Factory_initialize() {
{
TestFactory01::initialize(); TestFactory01::initialize();
} }
void Factory_build() void Factory_build() {
{
TestFactory01::build(); TestFactory01::build();
} }
StateMachine01 TestFactory01::task01_(1000, "Say Hello"); StateMachine01 TestFactory01::task01_(1000, "Say Hello");
StateMachine01 TestFactory01::task02_(500, "Echo"); StateMachine01 TestFactory01::task02_(500, "Echo");
TestFactory01::TestFactory01() TestFactory01::TestFactory01() {
{
} }
// static // static
void TestFactory01::initialize() void TestFactory01::initialize() {
{
} }
// static // static
void TestFactory01::build() void TestFactory01::build() {
{
Trace::out("Starting test1..."); Trace::out("Starting test1...");
Trace::out("---------------------"); Trace::out("---------------------");