summaryrefslogtreecommitdiff
path: root/Kernel/Net
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-08-19 17:26:07 +0200
committerAndreas Kling <kling@serenityos.org>2022-08-20 17:15:52 +0200
commite475263113387404e63cdc3666391934604eb6e7 (patch)
tree5d15d4f41a7811f58171b6e8bdd6ae014e2bea7d /Kernel/Net
parent4889eb019a47478e50e1876f9584356e957e4ea4 (diff)
downloadserenity-e475263113387404e63cdc3666391934604eb6e7.zip
AK+Kernel: Add AK::AtomicRefCounted and use everywhere in the kernel
Instead of having two separate implementations of AK::RefCounted, one for userspace and one for kernelspace, there is now RefCounted and AtomicRefCounted.
Diffstat (limited to 'Kernel/Net')
-rw-r--r--Kernel/Net/NetworkAdapter.h6
-rw-r--r--Kernel/Net/Routing.h2
-rw-r--r--Kernel/Net/Socket.h1
3 files changed, 5 insertions, 4 deletions
diff --git a/Kernel/Net/NetworkAdapter.h b/Kernel/Net/NetworkAdapter.h
index 3f39274d3c..d465e378ec 100644
--- a/Kernel/Net/NetworkAdapter.h
+++ b/Kernel/Net/NetworkAdapter.h
@@ -6,6 +6,7 @@
#pragma once
+#include <AK/AtomicRefCounted.h>
#include <AK/ByteBuffer.h>
#include <AK/Function.h>
#include <AK/IntrusiveList.h>
@@ -27,7 +28,7 @@ class NetworkAdapter;
using NetworkByteBuffer = AK::Detail::ByteBuffer<1500>;
-struct PacketWithTimestamp : public RefCounted<PacketWithTimestamp> {
+struct PacketWithTimestamp final : public AtomicRefCounted<PacketWithTimestamp> {
PacketWithTimestamp(NonnullOwnPtr<KBuffer> buffer, Time timestamp)
: buffer(move(buffer))
, timestamp(timestamp)
@@ -41,7 +42,8 @@ struct PacketWithTimestamp : public RefCounted<PacketWithTimestamp> {
IntrusiveListNode<PacketWithTimestamp, RefPtr<PacketWithTimestamp>> packet_node;
};
-class NetworkAdapter : public RefCounted<NetworkAdapter>
+class NetworkAdapter
+ : public AtomicRefCounted<NetworkAdapter>
, public Weakable<NetworkAdapter> {
public:
static constexpr i32 LINKSPEED_INVALID = -1;
diff --git a/Kernel/Net/Routing.h b/Kernel/Net/Routing.h
index ba7f06f2d2..fc3d4402cf 100644
--- a/Kernel/Net/Routing.h
+++ b/Kernel/Net/Routing.h
@@ -14,7 +14,7 @@
namespace Kernel {
-struct Route : public RefCounted<Route> {
+struct Route final : public AtomicRefCounted<Route> {
Route(IPv4Address const& destination, IPv4Address const& gateway, IPv4Address const& netmask, u16 flags, NonnullRefPtr<NetworkAdapter> adapter)
: destination(destination)
, gateway(gateway)
diff --git a/Kernel/Net/Socket.h b/Kernel/Net/Socket.h
index 281d530e9b..8622d52af4 100644
--- a/Kernel/Net/Socket.h
+++ b/Kernel/Net/Socket.h
@@ -8,7 +8,6 @@
#include <AK/Error.h>
#include <AK/NonnullRefPtrVector.h>
-#include <AK/RefCounted.h>
#include <AK/RefPtr.h>
#include <AK/Time.h>
#include <Kernel/FileSystem/File.h>