54 lines
1.3 KiB
C++
54 lines
1.3 KiB
C++
/***
|
|
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;
|
|
virtual bool HasNonTrivialCleanup() override;
|
|
|
|
bool HasBeenSignaled();
|
|
|
|
private:
|
|
AuUInt threadId {};
|
|
AuSPtr<CompletionGroup::ICompletionGroup> pCompletionGroup;
|
|
AuMutex mutex;
|
|
AuSPtr<APCLessEvent> pEvent;
|
|
bool bHasCalledBack {};
|
|
volatile bool bHasFinished {};
|
|
};
|
|
} |