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