Lifecycle management of threads #29

Merged
harraiken merged 240 commits from threads into master 2026-09-07 13:45:09 +02:00
Showing only changes of commit 577621e082 - Show all commits

View File

@@ -53,6 +53,40 @@ namespace KE
CriticalRegionGuard& operator=(const CriticalRegionGuard&) = delete; CriticalRegionGuard& operator=(const CriticalRegionGuard&) = delete;
}; };
class GuardedRegionGuard
{
private:
BOOLEAN Owned;
PKTHREAD SystemThread;
public:
GuardedRegionGuard(IN PKTHREAD Thread = NULLPTR,
IN BOOLEAN Acquire = TRUE)
{
Owned = Acquire;
SystemThread = Thread;
if(Owned)
{
if(!SystemThread)
{
SystemThread = KE::Processor::GetCurrentThread();
}
KE::KThread::EnterGuardedRegion(SystemThread);
}
}
~GuardedRegionGuard()
{
if(Owned)
{
KE::KThread::LeaveGuardedRegion(SystemThread);
}
}
GuardedRegionGuard(const GuardedRegionGuard&) = delete;
GuardedRegionGuard& operator=(const GuardedRegionGuard&) = delete;
};
class PushLockExclusiveGuard class PushLockExclusiveGuard
{ {
private: private: