AuroraRuntime/Source/IO/AuIOProcessorItems.cpp

52 lines
1.4 KiB
C++
Raw Normal View History

/***
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>
#include "AuIOProcessorItem.hpp"
#include "AuIOProcessorItems.hpp"
#include "AuIOProcessor.hpp"
namespace Aurora::IO
{
bool IOProcessorItems::Init()
{
2022-06-14 01:14:51 +00:00
this->cvEvent = AuLoop::NewLSEvent(false, true, true);
return bool(this->cvEvent);
}
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();
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, {});
}
}