diff --git a/Include/Aurora/IO/CompletionGroup/ICompletionGroup.hpp b/Include/Aurora/IO/CompletionGroup/ICompletionGroup.hpp index 10521e5d..df70c60e 100644 --- a/Include/Aurora/IO/CompletionGroup/ICompletionGroup.hpp +++ b/Include/Aurora/IO/CompletionGroup/ICompletionGroup.hpp @@ -35,6 +35,10 @@ namespace Aurora::IO::CompletionGroup virtual AuSPtr GetTriggerLoopSource() = 0; virtual void TryTrigger() = 0; + + // 0 = indefinite + virtual bool WaitForAnyMS(AuUInt32 uTimeoutOrZeroMS = 0) = 0; + virtual bool WaitForAllMS(AuUInt32 uTimeoutOrZeroMS = 0) = 0; }; AUKN_SYM AuSPtr NewCompletionGroup(); diff --git a/Source/IO/CompletionGroup/CompletionGroup.cpp b/Source/IO/CompletionGroup/CompletionGroup.cpp index 7bfd19de..cd43e96f 100644 --- a/Source/IO/CompletionGroup/CompletionGroup.cpp +++ b/Source/IO/CompletionGroup/CompletionGroup.cpp @@ -151,6 +151,30 @@ namespace Aurora::IO::CompletionGroup return this->anyProbablyAlwaysPresentEvent.GetLoopSource(); } + bool CompletionGroup::WaitForAnyMS(AuUInt32 uTimeoutOrZeroMS) + { + if (auto pLoopSource = this->ToAnyLoopSource()) + { + return pLoopSource->WaitOn(uTimeoutOrZeroMS); + } + else + { + return false; + } + } + + bool CompletionGroup::WaitForAllMS(AuUInt32 uTimeoutOrZeroMS) + { + if (auto pLoopSource = this->ToAndLoopSource()) + { + return pLoopSource->WaitOn(uTimeoutOrZeroMS); + } + else + { + return false; + } + } + void CompletionGroup::TryTrigger() { if (auto pSource = GetTriggerLoopSource()) diff --git a/Source/IO/CompletionGroup/CompletionGroup.hpp b/Source/IO/CompletionGroup/CompletionGroup.hpp index e4b9eb5b..aa91fab4 100644 --- a/Source/IO/CompletionGroup/CompletionGroup.hpp +++ b/Source/IO/CompletionGroup/CompletionGroup.hpp @@ -24,6 +24,9 @@ namespace Aurora::IO::CompletionGroup AuSPtr OnCompletion() override; AuSPtr OnSingleCompletion() override; + bool WaitForAnyMS(AuUInt32 uTimeoutOrZeroMS) override; + bool WaitForAllMS(AuUInt32 uTimeoutOrZeroMS) override; + AuSPtr GetTriggerLoopSource() override; void TryTrigger() override;