From 6d83b2d8f0a73695ee1c8eb5ea457268ac84e119 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Boric Date: Sun, 18 Jul 2021 11:47:09 +0200 Subject: [PATCH] Kernel: Migrate FIFO table locking to ProtectedValue --- Kernel/FileSystem/FIFO.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Kernel/FileSystem/FIFO.cpp b/Kernel/FileSystem/FIFO.cpp index 87a5c4e628..ed1daea882 100644 --- a/Kernel/FileSystem/FIFO.cpp +++ b/Kernel/FileSystem/FIFO.cpp @@ -10,16 +10,16 @@ #include #include #include -#include #include +#include #include #include namespace Kernel { -static AK::Singleton>> s_table; +static AK::Singleton>> s_table; -static Lockable>& all_fifos() +static ProtectedValue>& all_fifos() { return *s_table; } @@ -79,8 +79,9 @@ FIFO::FIFO(uid_t uid, NonnullOwnPtr buffer) : m_buffer(move(buffer)) , m_uid(uid) { - MutexLocker locker(all_fifos().lock()); - all_fifos().resource().set(this); + all_fifos().with_exclusive([&](auto& table) { + table.set(this); + }); m_fifo_id = ++s_next_fifo_id; // Use the same block condition for read and write @@ -91,8 +92,9 @@ FIFO::FIFO(uid_t uid, NonnullOwnPtr buffer) FIFO::~FIFO() { - MutexLocker locker(all_fifos().lock()); - all_fifos().resource().remove(this); + all_fifos().with_exclusive([&](auto& table) { + table.remove(this); + }); } void FIFO::attach(Direction direction)