1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 05:47:34 +00:00

Kernel: Rename ProtectedValue<T> => MutexProtected<T>

Let's make it obvious what we're protecting it with.
This commit is contained in:
Andreas Kling 2021-08-21 23:31:15 +02:00
parent 81d990b551
commit c2fc33becd
18 changed files with 57 additions and 56 deletions

View file

@ -26,11 +26,11 @@
namespace Kernel {
static Singleton<ProtectedValue<IPv4Socket::List>> s_all_sockets;
static Singleton<MutexProtected<IPv4Socket::List>> s_all_sockets;
using BlockFlags = Thread::FileDescriptionBlocker::BlockFlags;
ProtectedValue<IPv4Socket::List>& IPv4Socket::all_sockets()
MutexProtected<IPv4Socket::List>& IPv4Socket::all_sockets()
{
return *s_all_sockets;
}

View file

@ -10,7 +10,7 @@
#include <AK/SinglyLinkedListWithCount.h>
#include <Kernel/DoubleBuffer.h>
#include <Kernel/KBuffer.h>
#include <Kernel/Locking/ProtectedValue.h>
#include <Kernel/Locking/MutexProtected.h>
#include <Kernel/Net/IPv4.h>
#include <Kernel/Net/IPv4SocketTuple.h>
#include <Kernel/Net/Socket.h>
@ -135,7 +135,7 @@ private:
public:
using List = IntrusiveList<IPv4Socket, RawPtr<IPv4Socket>, &IPv4Socket::m_list_node>;
static ProtectedValue<IPv4Socket::List>& all_sockets();
static MutexProtected<IPv4Socket::List>& all_sockets();
};
}

View file

@ -10,7 +10,7 @@
#include <Kernel/FileSystem/FileDescription.h>
#include <Kernel/FileSystem/VirtualFileSystem.h>
#include <Kernel/Locking/Mutex.h>
#include <Kernel/Locking/ProtectedValue.h>
#include <Kernel/Locking/MutexProtected.h>
#include <Kernel/Net/LocalSocket.h>
#include <Kernel/Process.h>
#include <Kernel/StdLib.h>
@ -19,9 +19,9 @@
namespace Kernel {
static Singleton<ProtectedValue<LocalSocket::List>> s_list;
static Singleton<MutexProtected<LocalSocket::List>> s_list;
static ProtectedValue<LocalSocket::List>& all_sockets()
static MutexProtected<LocalSocket::List>& all_sockets()
{
return *s_list;
}

View file

@ -6,7 +6,7 @@
#include <Kernel/Debug.h>
#include <Kernel/Locking/Mutex.h>
#include <Kernel/Locking/ProtectedValue.h>
#include <Kernel/Locking/MutexProtected.h>
#include <Kernel/Net/ARP.h>
#include <Kernel/Net/EtherType.h>
#include <Kernel/Net/EthernetFrameHeader.h>

View file

@ -7,7 +7,7 @@
#include <AK/HashMap.h>
#include <AK/Singleton.h>
#include <Kernel/Debug.h>
#include <Kernel/Locking/ProtectedValue.h>
#include <Kernel/Locking/MutexProtected.h>
#include <Kernel/Net/LoopbackAdapter.h>
#include <Kernel/Net/NetworkTask.h>
#include <Kernel/Net/NetworkingManagement.h>
@ -16,7 +16,7 @@
namespace Kernel {
static Singleton<ProtectedValue<HashMap<IPv4Address, MACAddress>>> s_arp_table;
static Singleton<MutexProtected<HashMap<IPv4Address, MACAddress>>> s_arp_table;
class ARPTableBlocker : public Thread::Blocker {
public:
@ -104,7 +104,7 @@ void ARPTableBlocker::not_blocking(bool timeout_in_past)
}
}
ProtectedValue<HashMap<IPv4Address, MACAddress>>& arp_table()
MutexProtected<HashMap<IPv4Address, MACAddress>>& arp_table()
{
return *s_arp_table;
}

View file

@ -6,7 +6,7 @@
#pragma once
#include <Kernel/Locking/ProtectedValue.h>
#include <Kernel/Locking/MutexProtected.h>
#include <Kernel/Net/NetworkAdapter.h>
#include <Kernel/Thread.h>
@ -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<NetworkAdapter> through = nullptr);
ProtectedValue<HashMap<IPv4Address, MACAddress>>& arp_table();
MutexProtected<HashMap<IPv4Address, MACAddress>>& arp_table();
}

View file

@ -9,7 +9,7 @@
#include <Kernel/Debug.h>
#include <Kernel/Devices/RandomDevice.h>
#include <Kernel/FileSystem/FileDescription.h>
#include <Kernel/Locking/ProtectedValue.h>
#include <Kernel/Locking/MutexProtected.h>
#include <Kernel/Net/EthernetFrameHeader.h>
#include <Kernel/Net/IPv4.h>
#include <Kernel/Net/NetworkAdapter.h>
@ -56,16 +56,16 @@ void TCPSocket::set_state(State new_state)
evaluate_block_conditions();
}
static Singleton<ProtectedValue<HashMap<IPv4SocketTuple, RefPtr<TCPSocket>>>> s_socket_closing;
static Singleton<MutexProtected<HashMap<IPv4SocketTuple, RefPtr<TCPSocket>>>> s_socket_closing;
ProtectedValue<HashMap<IPv4SocketTuple, RefPtr<TCPSocket>>>& TCPSocket::closing_sockets()
MutexProtected<HashMap<IPv4SocketTuple, RefPtr<TCPSocket>>>& TCPSocket::closing_sockets()
{
return *s_socket_closing;
}
static Singleton<ProtectedValue<HashMap<IPv4SocketTuple, TCPSocket*>>> s_socket_tuples;
static Singleton<MutexProtected<HashMap<IPv4SocketTuple, TCPSocket*>>> s_socket_tuples;
ProtectedValue<HashMap<IPv4SocketTuple, TCPSocket*>>& TCPSocket::sockets_by_tuple()
MutexProtected<HashMap<IPv4SocketTuple, TCPSocket*>>& TCPSocket::sockets_by_tuple()
{
return *s_socket_tuples;
}
@ -512,9 +512,9 @@ KResult TCPSocket::close()
return result;
}
static Singleton<ProtectedValue<TCPSocket::RetransmitList>> s_sockets_for_retransmit;
static Singleton<MutexProtected<TCPSocket::RetransmitList>> s_sockets_for_retransmit;
ProtectedValue<TCPSocket::RetransmitList>& TCPSocket::sockets_for_retransmit()
MutexProtected<TCPSocket::RetransmitList>& TCPSocket::sockets_for_retransmit()
{
return *s_sockets_for_retransmit;
}

View file

@ -11,7 +11,7 @@
#include <AK/SinglyLinkedList.h>
#include <AK/WeakPtr.h>
#include <Kernel/KResult.h>
#include <Kernel/Locking/ProtectedValue.h>
#include <Kernel/Locking/MutexProtected.h>
#include <Kernel/Net/IPv4Socket.h>
namespace Kernel {
@ -142,10 +142,10 @@ public:
bool should_delay_next_ack() const;
static ProtectedValue<HashMap<IPv4SocketTuple, TCPSocket*>>& sockets_by_tuple();
static MutexProtected<HashMap<IPv4SocketTuple, TCPSocket*>>& sockets_by_tuple();
static RefPtr<TCPSocket> from_tuple(const IPv4SocketTuple& tuple);
static ProtectedValue<HashMap<IPv4SocketTuple, RefPtr<TCPSocket>>>& closing_sockets();
static MutexProtected<HashMap<IPv4SocketTuple, RefPtr<TCPSocket>>>& closing_sockets();
RefPtr<TCPSocket> 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<UnackedPackets> m_unacked_packets;
MutexProtected<UnackedPackets> m_unacked_packets;
u32 m_duplicate_acks { 0 };
@ -226,7 +226,7 @@ private:
public:
using RetransmitList = IntrusiveList<TCPSocket, RawPtr<TCPSocket>, &TCPSocket::m_retransmit_list_node>;
static ProtectedValue<TCPSocket::RetransmitList>& sockets_for_retransmit();
static MutexProtected<TCPSocket::RetransmitList>& sockets_for_retransmit();
};
}

View file

@ -22,9 +22,9 @@ void UDPSocket::for_each(Function<void(const UDPSocket&)> callback)
});
}
static Singleton<ProtectedValue<HashMap<u16, UDPSocket*>>> s_map;
static Singleton<MutexProtected<HashMap<u16, UDPSocket*>>> s_map;
ProtectedValue<HashMap<u16, UDPSocket*>>& UDPSocket::sockets_by_port()
MutexProtected<HashMap<u16, UDPSocket*>>& UDPSocket::sockets_by_port()
{
return *s_map;
}

View file

@ -7,7 +7,7 @@
#pragma once
#include <Kernel/KResult.h>
#include <Kernel/Locking/ProtectedValue.h>
#include <Kernel/Locking/MutexProtected.h>
#include <Kernel/Net/IPv4Socket.h>
namespace Kernel {
@ -23,7 +23,7 @@ public:
private:
explicit UDPSocket(int protocol, NonnullOwnPtr<DoubleBuffer> receive_buffer);
virtual StringView class_name() const override { return "UDPSocket"; }
static ProtectedValue<HashMap<u16, UDPSocket*>>& sockets_by_port();
static MutexProtected<HashMap<u16, UDPSocket*>>& sockets_by_port();
virtual KResultOr<size_t> protocol_receive(ReadonlyBytes raw_ipv4_packet, UserOrKernelBuffer& buffer, size_t buffer_size, int flags) override;
virtual KResultOr<size_t> protocol_send(const UserOrKernelBuffer&, size_t) override;