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
|
|
|
}
|
|
|
|
|
2023-12-11 20:18:36 +00:00
|
|
|
void IOProcessorItems::Deinit()
|
|
|
|
{
|
|
|
|
AU_LOCK_GUARD(this->mutex);
|
|
|
|
|
|
|
|
for (const auto &pItem : this->allItems)
|
|
|
|
{
|
|
|
|
pItem->pParent = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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);
|
2024-01-06 04:18:13 +00:00
|
|
|
bool bInsert = AuTryInsert(this->workSignaled2, item);
|
|
|
|
if (this->cvEvent)
|
|
|
|
{
|
|
|
|
this->cvEvent->Set();
|
|
|
|
}
|
|
|
|
return bInsert;
|
2022-06-11 23:01:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IOProcessorItems::ScheduleFinish(const AuSPtr<IOProcessorItem> &item, bool unsafe)
|
|
|
|
{
|
|
|
|
AU_TRY_LOCK_GUARD_RET_DEF(this->mutex);
|
2024-01-06 04:18:13 +00:00
|
|
|
auto bRet = AuTryInsert(this->crossThreadAbort, AuMakePair(item, unsafe));
|
|
|
|
if (this->cvEvent)
|
|
|
|
{
|
|
|
|
this->cvEvent->Set();
|
|
|
|
}
|
|
|
|
return bRet;
|
2022-06-11 23:01:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
AuList<AuSPtr<IOProcessorItem>> IOProcessorItems::GetBlockedSignals()
|
|
|
|
{
|
|
|
|
AU_LOCK_GUARD(this->mutex2);
|
|
|
|
return AuExchange(this->workSignaled2, {});
|
|
|
|
}
|
|
|
|
}
|