[+] AuUTF8StringView polyfil

[*] NT Loop queue improvements
This commit is contained in:
Reece Wilson 2022-03-30 23:30:51 +01:00
parent 3e80022f95
commit 90af80ae2c
3 changed files with 109 additions and 11 deletions

View File

@ -0,0 +1,7 @@
#pragma once
// TODO:
using AuUTF8StringView = std::string_view;
using AuU8View = AuUTF8StringView;

View File

@ -32,6 +32,7 @@
#include <auROXTL/auMemoryModel.hpp>
#include <auROXTL/auOptionalEx.hpp>
#include <auROXTL/auString.hpp>
#include <auROXTL/auUTF8StringView.hpp>
#include <auROXTL/auFunctional.hpp>
#include <auROXTL/auArray.hpp>
#include <auROXTL/auList.hpp>

View File

@ -521,8 +521,98 @@ namespace Aurora::Loop
// Ingore the other unrelated errors (APC notification, timeout, etc)
}
// OK - All signals are set
// Take ownership of the queue ready for a potential purge of objects
StartUserAndTakeOwn();
ConsiderEvicitingTimeoutsAll();
// Le great iterate
Iterator queueIterator(this);
AuSInt indexOffset {};
for (queueIterator.Start(); queueIterator.End() != queueIterator.itr; )
{
bool shouldRemove {true};
auto &source = *queueIterator.itr;
if (source.source)
{
if (source.source->OnTrigger(source.source->Singular() ? source.source->GetHandle() : source.source->GetHandles()[0]))
{
AU_LOCK_GUARD(const_cast<AuThreadPrimitives::SpinLock *>(&source.lock)) // this spinlock really does feel like a hack
for (const auto &handler : source.callbacks.extended)
{
try
{
shouldRemove &= handler->OnFinished(source.source);
}
catch (...)
{
SysPushErrorCatch();
}
}
if (shouldRemove)
{
for (const auto &handler : source.callbacks.base)
{
try
{
shouldRemove &= handler->OnFinished(source.source);
}
catch (...)
{
SysPushErrorCatch();
}
}
}
if ((source.callbacks.base.empty()) &&
(source.callbacks.extended.empty()))
{
shouldRemove = false;
}
}
}
if (source.ConsiderTimeout())
{
shouldRemove = true;
}
source.source->OnFinishSleep();
if (shouldRemove)
{
if (source.source->GetType() == ELoopSource::eSourceWin32)
{
SysPanic("?");
}
else
{
AuUInt uHandles = (source.source->Singular() ? 1 : source.source->GetHandles().size());
int sOffset = -(uHandles);
if (this->handleArrayOr_.size() > MAXIMUM_WAIT_OBJECTS)
{
this->RemoveSourceNB(source.source);
this->willCommitInFuture_ = true;
}
else
{
AuRemoveRange(this->handleArrayOr_, queueIterator.startingIndexOr + indexOffset, uHandles);
AuRemoveRange(this->handleArrayAnd_, queueIterator.startingIndexAnd + indexOffset, uHandles);
queueIterator.Delete(this->loopSourceExs_.erase(queueIterator.itr));
continue;
}
}
}
//else
{
queueIterator.Next();
}
}
StartUserAndTakeOwn_Release();
return bReturnStatus;
@ -745,21 +835,21 @@ namespace Aurora::Loop
AU_LOCK_GUARD(const_cast<AuThreadPrimitives::SpinLock *>(&source.lock)) // this spinlock really does feel like a hack
for (const auto &handler : source.callbacks.base)
for (const auto &handler : source.callbacks.extended)
{
try
{
try
{
shouldRemove &= handler->OnFinished(source.source);
}
catch (...)
{
SysPushErrorCatch();
}
shouldRemove &= handler->OnFinished(source.source);
}
catch (...)
{
SysPushErrorCatch();
}
}
if (shouldRemove)
{
for (const auto &handler : source.callbacks.extended)
for (const auto &handler : source.callbacks.base)
{
try
{