54 lines
1.6 KiB
C++
54 lines
1.6 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<Async::IWorkItem> OnCompletion() override;
|
|
AuSPtr<Async::IWorkItem> OnSingleCompletion() override;
|
|
|
|
AuSPtr<Loop::ILSEvent> GetTriggerLoopSource() override;
|
|
void TryTrigger() override;
|
|
|
|
bool HasCompleted() override;
|
|
AuPair<AuUInt32, AuUInt32> GetStats() override;
|
|
void SetCallbacks(const AuSPtr<ICompletionGroupHooks> &pCallbacks) override;
|
|
|
|
void DoIOTick();
|
|
|
|
void ResetMemoryPins();
|
|
bool HasItemsActive();
|
|
|
|
void AddWorkItem(AuSPtr<ICompletionGroupWorkItem> pCompletable) override;
|
|
|
|
private:
|
|
AuMutex mutex;
|
|
AuCriticalSection cs;
|
|
CompletionQuantumEventProvider anyProbablyAlwaysPresentEvent;
|
|
CompletionQuantumEventProvider andPlsDontAllocateFdIfUntouchedEvent;
|
|
AuList<AuSPtr<ICompletionGroupWorkItem>> workItems;
|
|
AuSPtr<ICompletionGroupHooks> pCallbacks;
|
|
AuSPtr<Async::IWorkItem> pAnyBarrier;
|
|
AuSPtr<Async::IWorkItem> pAndBarrier;
|
|
AuUInt32 uAdded {};
|
|
AuUInt32 uTriggered {};
|
|
bool bNoAny {};
|
|
};
|
|
} |