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

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.
This commit is contained in:
Andreas Kling 2022-08-19 17:26:07 +02:00
parent 4889eb019a
commit e475263113
45 changed files with 81 additions and 94 deletions

View file

@ -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;

View file

@ -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)

View file

@ -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>