2022-06-11 23:01:27 +00:00
|
|
|
/***
|
|
|
|
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
|
|
|
|
File: IOProcessorItems.cpp
|
|
|
|
Date: 2022-6-6
|
|
|
|
Author: Reece
|
|
|
|
***/
|
|
|
|
#include <Source/RuntimeInternal.hpp>
|
|
|
|
#include <Aurora/IO/IOExperimental.hpp>
|
2022-12-17 20:14:19 +00:00
|
|
|
#include "AuIOProcessorItem.hpp"
|
|
|
|
#include "AuIOProcessorItems.hpp"
|
|
|
|
#include "AuIOProcessor.hpp"
|
2022-06-11 23:01:27 +00:00
|
|
|
|
|
|
|
namespace Aurora::IO
|
|
|
|
{
|
|
|
|
bool IOProcessorItems::Init()
|
|
|
|
{
|
2022-06-14 01:14:51 +00:00
|
|
|
this->cvEvent = AuLoop::NewLSEvent(false, true, true);
|
|
|
|
|
2023-06-28 09:33:12 +00:00
|
|
|
return bool(this->cvEvent);
|
2022-06-11 23:01:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool IOProcessorItems::AddFrameTemp(const AuSPtr<IOProcessorItem> &item)
|
|
|
|
{
|
|
|
|
AU_TRY_LOCK_GUARD_RET_DEF(this->mutex);
|
|
|
|
return AuTryInsert(this->workSignaled, item);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IOProcessorItems::AddFrameOrFallback(const AuSPtr<IOProcessorItem> &item)
|
|
|
|
{
|
|
|
|
if (!AddFrameTemp(item))
|
|
|
|
{
|
|
|
|
AU_LOCK_GUARD(this->mutex2);
|
2022-06-14 01:14:51 +00:00
|
|
|
this->cvEvent->Set();
|
2022-06-11 23:01:27 +00:00
|
|
|
return AuTryInsert(this->workSignaled2, item);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IOProcessorItems::ScheduleFinish(const AuSPtr<IOProcessorItem> &item, bool unsafe)
|
|
|
|
{
|
|
|
|
AU_TRY_LOCK_GUARD_RET_DEF(this->mutex);
|
|
|
|
return AuTryInsert(this->crossThreadAbort, AuMakePair(item, unsafe));
|
|
|
|
}
|
|
|
|
|
|
|
|
AuList<AuSPtr<IOProcessorItem>> IOProcessorItems::GetBlockedSignals()
|
|
|
|
{
|
|
|
|
AU_LOCK_GUARD(this->mutex2);
|
|
|
|
return AuExchange(this->workSignaled2, {});
|
|
|
|
}
|
|
|
|
}
|