mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 09:38:11 +00:00
Kernel: Convert IPv4 socket list from HashTable to IntrusiveList
There was no reason whatsoever to use a HashTable here. IntrusiveList removes all the heap allocations and does everything more efficiently.
This commit is contained in:
parent
a154faebb7
commit
7063303022
3 changed files with 17 additions and 10 deletions
|
@ -26,13 +26,13 @@
|
|||
|
||||
namespace Kernel {
|
||||
|
||||
static Singleton<ProtectedValue<HashTable<IPv4Socket*>>> s_table;
|
||||
static Singleton<ProtectedValue<IPv4Socket::List>> s_all_sockets;
|
||||
|
||||
using BlockFlags = Thread::FileDescriptionBlocker::BlockFlags;
|
||||
|
||||
ProtectedValue<HashTable<IPv4Socket*>>& IPv4Socket::all_sockets()
|
||||
ProtectedValue<IPv4Socket::List>& IPv4Socket::all_sockets()
|
||||
{
|
||||
return *s_table;
|
||||
return *s_all_sockets;
|
||||
}
|
||||
|
||||
OwnPtr<DoubleBuffer> IPv4Socket::create_receive_buffer()
|
||||
|
@ -79,14 +79,14 @@ IPv4Socket::IPv4Socket(int type, int protocol, NonnullOwnPtr<DoubleBuffer> recei
|
|||
}
|
||||
|
||||
all_sockets().with_exclusive([&](auto& table) {
|
||||
table.set(this);
|
||||
table.append(*this);
|
||||
});
|
||||
}
|
||||
|
||||
IPv4Socket::~IPv4Socket()
|
||||
{
|
||||
all_sockets().with_exclusive([&](auto& table) {
|
||||
table.remove(this);
|
||||
table.remove(*this);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue