Kernel: Add LockFreeGuard to LockGuard.h

This commit is contained in:
2024-02-09 15:13:54 +02:00
parent d452cf4170
commit 534b3e6a9a
3 changed files with 32 additions and 22 deletions

View File

@@ -227,28 +227,6 @@ namespace Kernel
}
}
// This to feels too hacky to expose out of here
struct LockFreeGuard
{
LockFreeGuard(RecursivePrioritySpinLock& lock)
: m_lock(lock)
, m_depth(lock.lock_depth())
{
for (uint32_t i = 0; i < m_depth; i++)
m_lock.unlock();
}
~LockFreeGuard()
{
for (uint32_t i = 0; i < m_depth; i++)
m_lock.lock();
}
private:
RecursivePrioritySpinLock& m_lock;
const uint32_t m_depth;
};
BAN::ErrorOr<void> UnixDomainSocket::add_packet(BAN::ConstByteSpan packet)
{
LockGuard _(m_lock);