AuroraRuntime/Source/IO/AuIOProcessorItems.cpp
Jamie Reece Wilson ca2c0462ab [*] Continue to refactor allocations of synchronization primitive away
[*] NT: Fix missing CoTaskMemFree leak on startup
[*] Fix ConsoleStd restart bug
2023-06-28 10:33:12 +01:00

52 lines
1.4 KiB
C++

/***
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()
{
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);
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, {});
}
}