69 lines
2.2 KiB
C++
69 lines
2.2 KiB
C++
/***
|
|
Copyright (C) 2023 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
File: CompletionGroup.hpp
|
|
Date: 2023-12-28
|
|
Author: Reece
|
|
***/
|
|
#pragma once
|
|
|
|
#include "CompletionQuantumEventProvider.hpp"
|
|
|
|
namespace Aurora::IO::CompletionGroup
|
|
{
|
|
struct CompletionGroup :
|
|
AuEnableSharedFromThis<CompletionGroup>,
|
|
ICompletionGroup
|
|
{
|
|
CompletionGroup();
|
|
~CompletionGroup();
|
|
|
|
AuSPtr<Loop::ILoopSource> ToAndLoopSource() override;
|
|
AuSPtr<Loop::ILoopSource> ToAnyLoopSource() override;
|
|
|
|
AuSPtr<AuAsync::IWorkItem> OnCompletion() override;
|
|
AuSPtr<AuAsync::IWorkItem> OnSingleCompletion() override;
|
|
|
|
bool WaitForAnyMS(AuUInt32 uTimeoutOrZeroMS) override;
|
|
bool WaitForAllMS(AuUInt32 uTimeoutOrZeroMS) override;
|
|
|
|
AuSPtr<Loop::ILSEvent> GetTriggerLoopSource() override;
|
|
void TryTrigger() override;
|
|
void TryTriggerLater() override;
|
|
|
|
bool HasCompleted() override;
|
|
AuPair<AuUInt32, AuUInt32> GetStats() override;
|
|
void SetCallbacks(const AuSPtr<ICompletionGroupHooks> &pCallbacks) override;
|
|
|
|
void DoIOTick(bool bManual);
|
|
|
|
void ResetMemoryPins();
|
|
bool HasItemsActive();
|
|
|
|
void AddWorkItem(const AuSPtr<ICompletionGroupWorkItem> &pCompletable) override;
|
|
void UnsafeRemoveItem(const AuSPtr<ICompletionGroupWorkItem> &pCompletable);
|
|
|
|
void AddCallbackTick(const AuSPtr<IIOProcessorManualInvoker> &pCallbackInvoker, bool bAny);
|
|
|
|
bool IsNeverEnding() override;
|
|
void SetNeverEnding(bool bValue) override;
|
|
|
|
void ResetAnd();
|
|
|
|
private:
|
|
AuMutex mutex;
|
|
AuCriticalSection cs;
|
|
CompletionQuantumEventProvider anyProbablyAlwaysPresentEvent;
|
|
CompletionQuantumEventProvider andPlsDontAllocateFdIfUntouchedEvent;
|
|
AuList<AuSPtr<ICompletionGroupWorkItem>> workItems;
|
|
AuSPtr<ICompletionGroupHooks> pCallbacks;
|
|
AuSPtr<AuAsync::IWorkItem> pAnyBarrier;
|
|
AuSPtr<AuAsync::IWorkItem> pAndBarrier;
|
|
AuList<AuPair<AuSPtr<IIOProcessorManualInvoker>, bool>> callbackTicks;
|
|
AuUInt32 uAdded {};
|
|
AuUInt32 uTriggered {};
|
|
bool bNoAny {};
|
|
bool bIsNeverEnding {};
|
|
bool bTerminated {};
|
|
};
|
|
} |