Reece Wilson
70418df761
> StartSimpleLSWatchEx > StartSimpleIOWatchEx > StartIOWatchEx [*] Update README
101 lines
2.3 KiB
C++
101 lines
2.3 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->parent->CheckThread() &&
|
|
this->parent->bFrameStart)
|
|
{
|
|
this->parent->ClearProcessor(AuSharedFromThis(), false);
|
|
return false;
|
|
}
|
|
|
|
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<AuLoop::ILoopSource>& source, AuUInt8 pos)
|
|
{
|
|
if (this->singleshot)
|
|
{
|
|
if (AuExchange(this->triggered, true))
|
|
{
|
|
StopWatch();
|
|
return true;
|
|
}
|
|
}
|
|
|
|
IOAlert(false);
|
|
|
|
if (this->singleshot)
|
|
{
|
|
StopWatch();
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
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->parent->IsTickOnly())
|
|
{
|
|
if (!this->parent->bFrameStart)
|
|
{
|
|
this->parent->TickFor(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");
|
|
}
|
|
}
|
|
}
|
|
} |