2024-02-26 16:48:10 +00:00
|
|
|
/***
|
|
|
|
Copyright (C) 2024 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
|
|
|
|
File: AuIOAPCLessWaitable.hpp
|
|
|
|
Date: 2024-2-25
|
|
|
|
Author: Reece
|
|
|
|
***/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Source/IO/Loop/LSEvent.hpp>
|
|
|
|
|
|
|
|
namespace Aurora::IO::Async
|
|
|
|
{
|
|
|
|
struct APCLessWaitable;
|
|
|
|
|
|
|
|
struct APCLessEvent : Loop::LSEvent
|
|
|
|
{
|
|
|
|
AuWPtr<APCLessWaitable> wpParent;
|
|
|
|
|
|
|
|
void OnFinishSleep() override;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct APCLessWaitable :
|
|
|
|
CompletionGroup::ICompletionGroupWorkItem,
|
|
|
|
AuEnableSharedFromThis<APCLessWaitable>
|
|
|
|
{
|
|
|
|
APCLessWaitable();
|
|
|
|
|
|
|
|
AuSPtr<Loop::ILoopSource> GetLoopSource();
|
|
|
|
void SignalComplete();
|
|
|
|
void CheckLocal();
|
|
|
|
|
|
|
|
bool TryAttachToCompletionGroup(const AuSPtr<CompletionGroup::ICompletionGroup> &pCompletionGroup);
|
|
|
|
AuSPtr<CompletionGroup::ICompletionGroup> GetCompletionGroup();
|
|
|
|
|
|
|
|
void Reset();
|
|
|
|
|
|
|
|
virtual void OnOriginThreadComplete() = 0;
|
|
|
|
|
|
|
|
virtual bool HasCompletedForGCWI() override;
|
|
|
|
virtual void CleanupForGCWI() override;
|
2024-02-27 10:51:56 +00:00
|
|
|
virtual bool HasNonTrivialCleanup() override;
|
2024-02-26 16:48:10 +00:00
|
|
|
|
|
|
|
bool HasBeenSignaled();
|
|
|
|
|
|
|
|
private:
|
|
|
|
AuUInt threadId {};
|
|
|
|
AuSPtr<CompletionGroup::ICompletionGroup> pCompletionGroup;
|
|
|
|
AuMutex mutex;
|
|
|
|
AuSPtr<APCLessEvent> pEvent;
|
|
|
|
bool bHasCalledBack {};
|
|
|
|
volatile bool bHasFinished {};
|
|
|
|
};
|
|
|
|
}
|