/*** Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. File: IOProcessorItem.cpp Date: 2022-6-6 Author: Reece ***/ #include #include #include "IOProcessorItem.hpp" #include "IOProcessor.hpp" namespace Aurora::IO { bool IOProcessorItem::StopWatch() { if (this->parent->CheckThread() && this->parent->bFrameStart) { this->parent->ClearProcessor(AuSharedFromThis(), false); return true; } return this->parent->items.ScheduleFinish(AuSharedFromThis(), false); } bool IOProcessorItem::FailWatch() { if (this->parent->CheckThread() && this->parent->bFrameStart) { this->parent->ClearProcessor(AuSharedFromThis(), true); return false; } return this->parent->items.ScheduleFinish(AuSharedFromThis(), true); } bool IOProcessorItem::OnFinished(const AuSPtr& source, AuUInt8 pos) { if (this->singleshot) { if (AuExchange(this->triggered, true)) { StopWatch(); return false; } } IOAlert(false); return this->singleshot; } void IOProcessorItem::OnTimeout(const AuSPtr& source) { SysPushErrorIO("IO Timeout"); this->FailWatch(); } void IOProcessorItem::InvokeManualTick() { IOAlert(true); } void IOProcessorItem::IOAlert(bool force) { if (!this->parent->IsTickOnly()) { if (!this->parent->bFrameStart) { if (force) { this->parent->TickFor(AuSharedFromThis()); } else { this->parent->TickForHack(AuSharedFromThis()); } } else { this->parent->TickForRegister(AuSharedFromThis()); } } else if (force) // manual tick { if (this->parent->CheckThread()) { this->parent->TickFor(AuSharedFromThis()); } else if (parent->IsAsync()) { // TODO: } else { SysPanic("Missing"); } } if (this->singleshot) { StopWatch(); } } }