diff --git a/Kernel/FileSystem/BlockBasedFileSystem.h b/Kernel/FileSystem/BlockBasedFileSystem.h index 2efbaf93b2..f9856b6c52 100644 --- a/Kernel/FileSystem/BlockBasedFileSystem.h +++ b/Kernel/FileSystem/BlockBasedFileSystem.h @@ -7,7 +7,7 @@ #pragma once #include -#include +#include namespace Kernel { @@ -44,7 +44,7 @@ private: DiskCache& cache() const; void flush_specific_block_if_needed(BlockIndex index); - mutable ProtectedValue> m_cache; + mutable MutexProtected> m_cache; }; } diff --git a/Kernel/FileSystem/Custody.cpp b/Kernel/FileSystem/Custody.cpp index b3c7876f34..7ba23bbe60 100644 --- a/Kernel/FileSystem/Custody.cpp +++ b/Kernel/FileSystem/Custody.cpp @@ -10,13 +10,13 @@ #include #include #include -#include +#include namespace Kernel { -static Singleton> s_all_custodies; +static Singleton> s_all_custodies; -static ProtectedValue& all_custodies() +static MutexProtected& all_custodies() { return s_all_custodies; } diff --git a/Kernel/FileSystem/VirtualFileSystem.h b/Kernel/FileSystem/VirtualFileSystem.h index 550ff23cc1..9218b50146 100644 --- a/Kernel/FileSystem/VirtualFileSystem.h +++ b/Kernel/FileSystem/VirtualFileSystem.h @@ -20,7 +20,7 @@ #include #include #include -#include +#include namespace Kernel { @@ -93,7 +93,7 @@ private: RefPtr m_root_inode; RefPtr m_root_custody; - ProtectedValue> m_mounts; + MutexProtected> m_mounts; }; } diff --git a/Kernel/Locking/ContendedResource.h b/Kernel/Locking/MutexContendedResource.h similarity index 86% rename from Kernel/Locking/ContendedResource.h rename to Kernel/Locking/MutexContendedResource.h index b3e597efde..6bb78eec7b 100644 --- a/Kernel/Locking/ContendedResource.h +++ b/Kernel/Locking/MutexContendedResource.h @@ -36,15 +36,15 @@ private: MutexLocker m_mutex_locker; }; -class ContendedResource { +class MutexContendedResource { template friend class LockedResource; - AK_MAKE_NONCOPYABLE(ContendedResource); - AK_MAKE_NONMOVABLE(ContendedResource); + AK_MAKE_NONCOPYABLE(MutexContendedResource); + AK_MAKE_NONMOVABLE(MutexContendedResource); public: - ContendedResource() = default; + MutexContendedResource() = default; protected: mutable Mutex m_mutex; diff --git a/Kernel/Locking/ProtectedValue.h b/Kernel/Locking/MutexProtected.h similarity index 79% rename from Kernel/Locking/ProtectedValue.h rename to Kernel/Locking/MutexProtected.h index ebc347674f..13761f9aa5 100644 --- a/Kernel/Locking/ProtectedValue.h +++ b/Kernel/Locking/MutexProtected.h @@ -6,28 +6,29 @@ #pragma once -#include #include +#include namespace Kernel { template -class ProtectedValue : private T - , public ContendedResource { - AK_MAKE_NONCOPYABLE(ProtectedValue); - AK_MAKE_NONMOVABLE(ProtectedValue); +class MutexProtected + : private T + , public MutexContendedResource { + AK_MAKE_NONCOPYABLE(MutexProtected); + AK_MAKE_NONMOVABLE(MutexProtected); protected: using LockedShared = LockedResource; using LockedExclusive = LockedResource; - LockedShared lock_shared(LockLocation const& location) const { return LockedShared(this, this->ContendedResource::m_mutex, location); } - LockedExclusive lock_exclusive(LockLocation const& location) { return LockedExclusive(this, this->ContendedResource::m_mutex, location); } + LockedShared lock_shared(LockLocation const& location) const { return LockedShared(this, this->MutexContendedResource::m_mutex, location); } + LockedExclusive lock_exclusive(LockLocation const& location) { return LockedExclusive(this, this->MutexContendedResource::m_mutex, location); } public: using T::T; - ProtectedValue() = default; + MutexProtected() = default; template decltype(auto) with_shared(Callback callback, LockLocation const& location = LockLocation::current()) const diff --git a/Kernel/Net/IPv4Socket.cpp b/Kernel/Net/IPv4Socket.cpp index 7b5c50c7a2..5c56c9dc72 100644 --- a/Kernel/Net/IPv4Socket.cpp +++ b/Kernel/Net/IPv4Socket.cpp @@ -26,11 +26,11 @@ namespace Kernel { -static Singleton> s_all_sockets; +static Singleton> s_all_sockets; using BlockFlags = Thread::FileDescriptionBlocker::BlockFlags; -ProtectedValue& IPv4Socket::all_sockets() +MutexProtected& IPv4Socket::all_sockets() { return *s_all_sockets; } diff --git a/Kernel/Net/IPv4Socket.h b/Kernel/Net/IPv4Socket.h index 0b01fa3784..0a52e5a181 100644 --- a/Kernel/Net/IPv4Socket.h +++ b/Kernel/Net/IPv4Socket.h @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include #include @@ -135,7 +135,7 @@ private: public: using List = IntrusiveList, &IPv4Socket::m_list_node>; - static ProtectedValue& all_sockets(); + static MutexProtected& all_sockets(); }; } diff --git a/Kernel/Net/LocalSocket.cpp b/Kernel/Net/LocalSocket.cpp index 322d390913..52523fd1bb 100644 --- a/Kernel/Net/LocalSocket.cpp +++ b/Kernel/Net/LocalSocket.cpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include #include @@ -19,9 +19,9 @@ namespace Kernel { -static Singleton> s_list; +static Singleton> s_list; -static ProtectedValue& all_sockets() +static MutexProtected& all_sockets() { return *s_list; } diff --git a/Kernel/Net/NetworkTask.cpp b/Kernel/Net/NetworkTask.cpp index ef781da2c4..d38d9e9ff0 100644 --- a/Kernel/Net/NetworkTask.cpp +++ b/Kernel/Net/NetworkTask.cpp @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include #include diff --git a/Kernel/Net/Routing.cpp b/Kernel/Net/Routing.cpp index b3155ef65f..bd8bf62198 100644 --- a/Kernel/Net/Routing.cpp +++ b/Kernel/Net/Routing.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include #include @@ -16,7 +16,7 @@ namespace Kernel { -static Singleton>> s_arp_table; +static Singleton>> s_arp_table; class ARPTableBlocker : public Thread::Blocker { public: @@ -104,7 +104,7 @@ void ARPTableBlocker::not_blocking(bool timeout_in_past) } } -ProtectedValue>& arp_table() +MutexProtected>& arp_table() { return *s_arp_table; } diff --git a/Kernel/Net/Routing.h b/Kernel/Net/Routing.h index edae3464eb..eeb7a12c7b 100644 --- a/Kernel/Net/Routing.h +++ b/Kernel/Net/Routing.h @@ -6,7 +6,7 @@ #pragma once -#include +#include #include #include @@ -27,6 +27,6 @@ enum class UpdateArp { void update_arp_table(const IPv4Address&, const MACAddress&, UpdateArp update); RoutingDecision route_to(const IPv4Address& target, const IPv4Address& source, const RefPtr through = nullptr); -ProtectedValue>& arp_table(); +MutexProtected>& arp_table(); } diff --git a/Kernel/Net/TCPSocket.cpp b/Kernel/Net/TCPSocket.cpp index 87ec059409..ac21e380fe 100644 --- a/Kernel/Net/TCPSocket.cpp +++ b/Kernel/Net/TCPSocket.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include @@ -56,16 +56,16 @@ void TCPSocket::set_state(State new_state) evaluate_block_conditions(); } -static Singleton>>> s_socket_closing; +static Singleton>>> s_socket_closing; -ProtectedValue>>& TCPSocket::closing_sockets() +MutexProtected>>& TCPSocket::closing_sockets() { return *s_socket_closing; } -static Singleton>> s_socket_tuples; +static Singleton>> s_socket_tuples; -ProtectedValue>& TCPSocket::sockets_by_tuple() +MutexProtected>& TCPSocket::sockets_by_tuple() { return *s_socket_tuples; } @@ -512,9 +512,9 @@ KResult TCPSocket::close() return result; } -static Singleton> s_sockets_for_retransmit; +static Singleton> s_sockets_for_retransmit; -ProtectedValue& TCPSocket::sockets_for_retransmit() +MutexProtected& TCPSocket::sockets_for_retransmit() { return *s_sockets_for_retransmit; } diff --git a/Kernel/Net/TCPSocket.h b/Kernel/Net/TCPSocket.h index 9d491e4db9..66b66834ce 100644 --- a/Kernel/Net/TCPSocket.h +++ b/Kernel/Net/TCPSocket.h @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include namespace Kernel { @@ -142,10 +142,10 @@ public: bool should_delay_next_ack() const; - static ProtectedValue>& sockets_by_tuple(); + static MutexProtected>& sockets_by_tuple(); static RefPtr from_tuple(const IPv4SocketTuple& tuple); - static ProtectedValue>>& closing_sockets(); + static MutexProtected>>& closing_sockets(); RefPtr create_client(const IPv4Address& local_address, u16 local_port, const IPv4Address& peer_address, u16 peer_port); void set_originator(TCPSocket& originator) { m_originator = originator; } @@ -207,7 +207,7 @@ private: size_t size { 0 }; }; - ProtectedValue m_unacked_packets; + MutexProtected m_unacked_packets; u32 m_duplicate_acks { 0 }; @@ -226,7 +226,7 @@ private: public: using RetransmitList = IntrusiveList, &TCPSocket::m_retransmit_list_node>; - static ProtectedValue& sockets_for_retransmit(); + static MutexProtected& sockets_for_retransmit(); }; } diff --git a/Kernel/Net/UDPSocket.cpp b/Kernel/Net/UDPSocket.cpp index 170663fc32..8702517afb 100644 --- a/Kernel/Net/UDPSocket.cpp +++ b/Kernel/Net/UDPSocket.cpp @@ -22,9 +22,9 @@ void UDPSocket::for_each(Function callback) }); } -static Singleton>> s_map; +static Singleton>> s_map; -ProtectedValue>& UDPSocket::sockets_by_port() +MutexProtected>& UDPSocket::sockets_by_port() { return *s_map; } diff --git a/Kernel/Net/UDPSocket.h b/Kernel/Net/UDPSocket.h index d57ff39445..58d011c33c 100644 --- a/Kernel/Net/UDPSocket.h +++ b/Kernel/Net/UDPSocket.h @@ -7,7 +7,7 @@ #pragma once #include -#include +#include #include namespace Kernel { @@ -23,7 +23,7 @@ public: private: explicit UDPSocket(int protocol, NonnullOwnPtr receive_buffer); virtual StringView class_name() const override { return "UDPSocket"; } - static ProtectedValue>& sockets_by_port(); + static MutexProtected>& sockets_by_port(); virtual KResultOr protocol_receive(ReadonlyBytes raw_ipv4_packet, UserOrKernelBuffer& buffer, size_t buffer_size, int flags) override; virtual KResultOr protocol_send(const UserOrKernelBuffer&, size_t) override; diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index 0fdc1bec95..dc59ca5066 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -44,18 +44,18 @@ static void create_signal_trampoline(); RecursiveSpinLock g_profiling_lock; static Atomic next_pid; -static Singleton> s_processes; +static Singleton> s_processes; READONLY_AFTER_INIT HashMap>* g_modules; READONLY_AFTER_INIT Memory::Region* g_signal_trampoline_region; -static Singleton> s_hostname; +static Singleton> s_hostname; -ProtectedValue& hostname() +MutexProtected& hostname() { return *s_hostname; } -ProtectedValue& processes() +MutexProtected& processes() { return *s_processes; } diff --git a/Kernel/Process.h b/Kernel/Process.h index 176582fbc2..07edcd12a1 100644 --- a/Kernel/Process.h +++ b/Kernel/Process.h @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include #include @@ -37,7 +37,7 @@ namespace Kernel { -ProtectedValue& hostname(); +MutexProtected& hostname(); Time kgettimeofday(); #define ENUMERATE_PLEDGE_PROMISES \ @@ -814,7 +814,7 @@ static_assert(sizeof(Process) == (PAGE_SIZE * 2)); extern RecursiveSpinLock g_profiling_lock; -ProtectedValue& processes(); +MutexProtected& processes(); template Callback> inline void Process::for_each(Callback callback) diff --git a/Kernel/TTY/PTYMultiplexer.h b/Kernel/TTY/PTYMultiplexer.h index 4c7f489242..4b5c38d00b 100644 --- a/Kernel/TTY/PTYMultiplexer.h +++ b/Kernel/TTY/PTYMultiplexer.h @@ -44,7 +44,7 @@ private: virtual StringView class_name() const override { return "PTYMultiplexer"; } static constexpr size_t max_pty_pairs = 64; - ProtectedValue> m_freelist; + MutexProtected> m_freelist; }; }