1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 00:37:45 +00:00

Revert "Kernel: Switch singletons to use new Singleton class"

This reverts commit f48feae0b2.
This commit is contained in:
Andreas Kling 2020-08-22 17:53:34 +02:00
parent 0addcb45b8
commit 2fd9e72264
44 changed files with 146 additions and 184 deletions

View file

@ -25,7 +25,6 @@
*/
#include <AK/StringBuilder.h>
#include <Kernel/Singleton.h>
#include <Kernel/FileSystem/FileDescription.h>
#include <Kernel/Net/ARP.h>
#include <Kernel/Net/ICMP.h>
@ -46,10 +45,11 @@
namespace Kernel {
static auto s_table = make_singleton<Lockable<HashTable<IPv4Socket*>>>();
Lockable<HashTable<IPv4Socket*>>& IPv4Socket::all_sockets()
{
static Lockable<HashTable<IPv4Socket*>>* s_table;
if (!s_table)
s_table = new Lockable<HashTable<IPv4Socket*>>;
return *s_table;
}

View file

@ -29,7 +29,6 @@
#include <Kernel/FileSystem/VirtualFileSystem.h>
#include <Kernel/Net/LocalSocket.h>
#include <Kernel/Process.h>
#include <Kernel/Singleton.h>
#include <Kernel/StdLib.h>
#include <Kernel/UnixTypes.h>
#include <LibC/errno_numbers.h>
@ -38,10 +37,11 @@
namespace Kernel {
static auto s_list = make_singleton<Lockable<InlineLinkedList<LocalSocket>>>();
Lockable<InlineLinkedList<LocalSocket>>& LocalSocket::all_sockets()
{
static Lockable<InlineLinkedList<LocalSocket>>* s_list;
if (!s_list)
s_list = new Lockable<InlineLinkedList<LocalSocket>>();
return *s_list;
}

View file

@ -25,15 +25,15 @@
*/
#include <Kernel/Net/LoopbackAdapter.h>
#include <Kernel/Singleton.h>
namespace Kernel {
static auto s_loopback = make_singleton<LoopbackAdapter>();
LoopbackAdapter& LoopbackAdapter::the()
{
return *s_loopback;
static LoopbackAdapter* the;
if (!the)
the = new LoopbackAdapter;
return *the;
}
LoopbackAdapter::LoopbackAdapter()

View file

@ -33,13 +33,15 @@ namespace Kernel {
class LoopbackAdapter final : public NetworkAdapter {
AK_MAKE_ETERNAL
public:
LoopbackAdapter();
static LoopbackAdapter& the();
virtual ~LoopbackAdapter() override;
virtual void send_raw(ReadonlyBytes) override;
virtual const char* class_name() const override { return "LoopbackAdapter"; }
private:
LoopbackAdapter();
};
}

View file

@ -33,16 +33,16 @@
#include <Kernel/Net/LoopbackAdapter.h>
#include <Kernel/Net/NetworkAdapter.h>
#include <Kernel/Random.h>
#include <Kernel/Singleton.h>
#include <Kernel/StdLib.h>
namespace Kernel {
static auto s_table = make_singleton<Lockable<HashTable<NetworkAdapter*>>>();
static Lockable<HashTable<NetworkAdapter*>>& all_adapters()
{
return *s_table;
static Lockable<HashTable<NetworkAdapter*>>* table;
if (!table)
table = new Lockable<HashTable<NetworkAdapter*>>;
return *table;
}
void NetworkAdapter::for_each(Function<void(NetworkAdapter&)> callback)

View file

@ -28,17 +28,17 @@
#include <Kernel/Net/LoopbackAdapter.h>
#include <Kernel/Net/Routing.h>
#include <Kernel/Thread.h>
#include <Kernel/Singleton.h>
//#define ROUTING_DEBUG
namespace Kernel {
static auto s_arp_table = make_singleton<Lockable<HashMap<IPv4Address, MACAddress>>>();
Lockable<HashMap<IPv4Address, MACAddress>>& arp_table()
{
return *s_arp_table;
static Lockable<HashMap<IPv4Address, MACAddress>>* the;
if (!the)
the = new Lockable<HashMap<IPv4Address, MACAddress>>;
return *the;
}
bool RoutingDecision::is_zero() const

View file

@ -33,7 +33,6 @@
#include <Kernel/Net/TCPSocket.h>
#include <Kernel/Process.h>
#include <Kernel/Random.h>
#include <Kernel/Singleton.h>
//#define TCP_SOCKET_DEBUG
@ -71,10 +70,11 @@ Lockable<HashMap<IPv4SocketTuple, RefPtr<TCPSocket>>>& TCPSocket::closing_socket
return *s_map;
}
static auto s_map = make_singleton<Lockable<HashMap<IPv4SocketTuple, TCPSocket*>>>();
Lockable<HashMap<IPv4SocketTuple, TCPSocket*>>& TCPSocket::sockets_by_tuple()
{
static Lockable<HashMap<IPv4SocketTuple, TCPSocket*>>* s_map;
if (!s_map)
s_map = new Lockable<HashMap<IPv4SocketTuple, TCPSocket*>>;
return *s_map;
}

View file

@ -31,7 +31,6 @@
#include <Kernel/Net/UDPSocket.h>
#include <Kernel/Process.h>
#include <Kernel/Random.h>
#include <Kernel/Singleton.h>
namespace Kernel {
@ -42,10 +41,11 @@ void UDPSocket::for_each(Function<void(const UDPSocket&)> callback)
callback(*it.value);
}
static auto s_map = make_singleton<Lockable<HashMap<u16, UDPSocket*>>>();
Lockable<HashMap<u16, UDPSocket*>>& UDPSocket::sockets_by_port()
{
static Lockable<HashMap<u16, UDPSocket*>>* s_map;
if (!s_map)
s_map = new Lockable<HashMap<u16, UDPSocket*>>;
return *s_map;
}