mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-08-16 17:00:35 +03: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:
parent
4889eb019a
commit
e475263113
Notes:
sideshowbarker
2024-07-18 04:46:35 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/e475263113
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2018-2022, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
@ -15,9 +15,9 @@
|
||||
|
||||
namespace AK {
|
||||
|
||||
class RefCountedBase {
|
||||
AK_MAKE_NONCOPYABLE(RefCountedBase);
|
||||
AK_MAKE_NONMOVABLE(RefCountedBase);
|
||||
class AtomicRefCountedBase {
|
||||
AK_MAKE_NONCOPYABLE(AtomicRefCountedBase);
|
||||
AK_MAKE_NONMOVABLE(AtomicRefCountedBase);
|
||||
|
||||
public:
|
||||
using RefCountType = unsigned int;
|
||||
@ -48,8 +48,8 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
RefCountedBase() = default;
|
||||
~RefCountedBase()
|
||||
AtomicRefCountedBase() = default;
|
||||
~AtomicRefCountedBase()
|
||||
{
|
||||
VERIFY(m_ref_count.load(AK::MemoryOrder::memory_order_relaxed) == 0);
|
||||
}
|
||||
@ -65,7 +65,7 @@ protected:
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class RefCounted : public RefCountedBase {
|
||||
class AtomicRefCounted : public AtomicRefCountedBase {
|
||||
public:
|
||||
bool unref() const
|
||||
{
|
||||
@ -83,5 +83,5 @@ public:
|
||||
|
||||
}
|
||||
|
||||
using AK::RefCounted;
|
||||
using AK::RefCountedBase;
|
||||
using AK::AtomicRefCounted;
|
||||
using AK::AtomicRefCountedBase;
|
@ -6,15 +6,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef KERNEL
|
||||
# include <Kernel/Library/ThreadSafeRefCounted.h>
|
||||
#else
|
||||
|
||||
# include <AK/Assertions.h>
|
||||
# include <AK/Checked.h>
|
||||
# include <AK/Noncopyable.h>
|
||||
# include <AK/Platform.h>
|
||||
# include <AK/StdLibExtras.h>
|
||||
#include <AK/Assertions.h>
|
||||
#include <AK/Checked.h>
|
||||
#include <AK/Noncopyable.h>
|
||||
#include <AK/Platform.h>
|
||||
#include <AK/StdLibExtras.h>
|
||||
|
||||
namespace AK {
|
||||
|
||||
@ -67,7 +63,7 @@ public:
|
||||
if (new_ref_count == 0) {
|
||||
if constexpr (requires { that->will_be_destroyed(); })
|
||||
that->will_be_destroyed();
|
||||
delete static_cast<const T*>(this);
|
||||
delete static_cast<T const*>(this);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -78,5 +74,3 @@ public:
|
||||
|
||||
using AK::RefCounted;
|
||||
using AK::RefCountedBase;
|
||||
|
||||
#endif
|
||||
|
@ -6,14 +6,14 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/AtomicRefCounted.h>
|
||||
#include <AK/Types.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
class GenericInterruptHandler;
|
||||
|
||||
class IRQController : public RefCounted<IRQController> {
|
||||
class IRQController : public AtomicRefCounted<IRQController> {
|
||||
public:
|
||||
virtual ~IRQController() = default;
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/AtomicRefCounted.h>
|
||||
#include <AK/Types.h>
|
||||
#include <Kernel/Interrupts/GenericInterruptHandler.h>
|
||||
|
||||
@ -19,7 +19,7 @@ enum class IRQControllerType {
|
||||
i82093AA = 2 /* Intel 82093AA I/O ADVANCED PROGRAMMABLE INTERRUPT CONTROLLER (IOAPIC) */
|
||||
};
|
||||
|
||||
class IRQController : public RefCounted<IRQController> {
|
||||
class IRQController : public AtomicRefCounted<IRQController> {
|
||||
public:
|
||||
virtual ~IRQController() = default;
|
||||
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include <AK/Function.h>
|
||||
#include <AK/NonnullOwnPtr.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/Types.h>
|
||||
#include <Kernel/Arch/x86/IRQController.h>
|
||||
|
@ -6,14 +6,14 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/AtomicRefCounted.h>
|
||||
#include <AK/Error.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <Kernel/Bus/USB/USBDevice.h>
|
||||
#include <Kernel/Bus/USB/USBTransfer.h>
|
||||
|
||||
namespace Kernel::USB {
|
||||
|
||||
class USBController : public RefCounted<USBController> {
|
||||
class USBController : public AtomicRefCounted<USBController> {
|
||||
public:
|
||||
virtual ~USBController() = default;
|
||||
|
||||
|
@ -27,7 +27,7 @@ class USBConfiguration;
|
||||
//
|
||||
// https://www.ftdichip.com/Support/Documents/TechnicalNotes/TN_113_Simplified%20Description%20of%20USB%20Device%20Enumeration.pdf
|
||||
class Hub;
|
||||
class Device : public RefCounted<Device> {
|
||||
class Device : public AtomicRefCounted<Device> {
|
||||
public:
|
||||
enum class DeviceSpeed : u8 {
|
||||
FullSpeed = 0,
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/Types.h>
|
||||
#include <Kernel/Bus/USB/USBDevice.h>
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/AtomicRefCounted.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <Kernel/Bus/USB/PacketTypes.h>
|
||||
@ -17,7 +18,7 @@
|
||||
// TODO: Callback stuff in this class please!
|
||||
namespace Kernel::USB {
|
||||
|
||||
class Transfer : public RefCounted<Transfer> {
|
||||
class Transfer final : public AtomicRefCounted<Transfer> {
|
||||
public:
|
||||
static ErrorOr<NonnullRefPtr<Transfer>> try_create(Pipe&, u16 length, Memory::Region& dma_buffer);
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
namespace Kernel::VirtIO {
|
||||
class Console
|
||||
: public VirtIO::Device
|
||||
, public RefCounted<Console> {
|
||||
, public AtomicRefCounted<Console> {
|
||||
friend VirtIO::ConsolePort;
|
||||
|
||||
public:
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/AtomicRefCounted.h>
|
||||
#include <Kernel/Bus/VirtIO/Device.h>
|
||||
#include <Kernel/Devices/CharacterDevice.h>
|
||||
#include <Kernel/Random.h>
|
||||
@ -16,7 +16,7 @@ namespace Kernel::VirtIO {
|
||||
#define REQUESTQ 0
|
||||
|
||||
class RNG final
|
||||
: public RefCounted<RNG>
|
||||
: public AtomicRefCounted<RNG>
|
||||
, public VirtIO::Device {
|
||||
public:
|
||||
static NonnullRefPtr<RNG> must_create(PCI::DeviceIdentifier const&);
|
||||
|
@ -20,7 +20,7 @@ class Device;
|
||||
|
||||
extern WorkQueue* g_io_work;
|
||||
|
||||
class AsyncDeviceRequest : public RefCounted<AsyncDeviceRequest> {
|
||||
class AsyncDeviceRequest : public AtomicRefCounted<AsyncDeviceRequest> {
|
||||
AK_MAKE_NONCOPYABLE(AsyncDeviceRequest);
|
||||
AK_MAKE_NONMOVABLE(AsyncDeviceRequest);
|
||||
|
||||
|
@ -23,7 +23,7 @@ namespace Kernel {
|
||||
|
||||
class AudioManagement;
|
||||
class AudioController
|
||||
: public RefCounted<AudioController>
|
||||
: public AtomicRefCounted<AudioController>
|
||||
, public Weakable<AudioController> {
|
||||
friend class AudioManagement;
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/AtomicRefCounted.h>
|
||||
#include <Kernel/Devices/HID/KeyboardDevice.h>
|
||||
#include <Kernel/Devices/HID/MouseDevice.h>
|
||||
#include <Kernel/Locking/Spinlock.h>
|
||||
@ -83,7 +83,7 @@ protected:
|
||||
class PS2KeyboardDevice;
|
||||
class PS2MouseDevice;
|
||||
class HIDManagement;
|
||||
class I8042Controller : public RefCounted<I8042Controller> {
|
||||
class I8042Controller final : public AtomicRefCounted<I8042Controller> {
|
||||
friend class PS2KeyboardDevice;
|
||||
friend class PS2MouseDevice;
|
||||
|
||||
|
@ -6,9 +6,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/AtomicRefCounted.h>
|
||||
#include <AK/Error.h>
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <AK/Types.h>
|
||||
#include <AK/Weakable.h>
|
||||
@ -71,10 +71,10 @@ public:
|
||||
// - Should create a Region in the Process and return it if successful.
|
||||
|
||||
class File
|
||||
: public RefCounted<File>
|
||||
: public AtomicRefCounted<File>
|
||||
, public Weakable<File> {
|
||||
public:
|
||||
virtual bool unref() const { return RefCounted<File>::unref(); }
|
||||
virtual bool unref() const { return AtomicRefCounted<File>::unref(); }
|
||||
virtual void will_be_destroyed() { }
|
||||
virtual ~File();
|
||||
|
||||
|
@ -6,8 +6,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/AtomicRefCounted.h>
|
||||
#include <AK/Error.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <Kernel/FileSystem/InodeIdentifier.h>
|
||||
@ -18,7 +18,7 @@
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
class FileSystem : public RefCounted<FileSystem> {
|
||||
class FileSystem : public AtomicRefCounted<FileSystem> {
|
||||
friend class Inode;
|
||||
|
||||
public:
|
||||
|
@ -283,7 +283,7 @@ class ISO9660FS final : public BlockBasedFileSystem {
|
||||
friend ISO9660DirectoryIterator;
|
||||
|
||||
public:
|
||||
struct DirectoryEntry : public RefCounted<DirectoryEntry> {
|
||||
struct DirectoryEntry final : public AtomicRefCounted<DirectoryEntry> {
|
||||
u32 extent { 0 };
|
||||
u32 length { 0 };
|
||||
|
||||
|
@ -6,8 +6,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/AtomicRefCounted.h>
|
||||
#include <AK/Badge.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <Kernel/FileSystem/FIFO.h>
|
||||
#include <Kernel/FileSystem/Inode.h>
|
||||
#include <Kernel/FileSystem/InodeMetadata.h>
|
||||
@ -22,7 +22,7 @@ public:
|
||||
virtual ~OpenFileDescriptionData() = default;
|
||||
};
|
||||
|
||||
class OpenFileDescription : public RefCounted<OpenFileDescription> {
|
||||
class OpenFileDescription final : public AtomicRefCounted<OpenFileDescription> {
|
||||
public:
|
||||
static ErrorOr<NonnullRefPtr<OpenFileDescription>> try_create(Custody&);
|
||||
static ErrorOr<NonnullRefPtr<OpenFileDescription>> try_create(File&);
|
||||
|
@ -69,7 +69,7 @@ private:
|
||||
mutable Spinlock m_lock { LockRank::None };
|
||||
};
|
||||
|
||||
struct ReceiveCompletion : public RefCounted<ReceiveCompletion> {
|
||||
struct ReceiveCompletion final : public AtomicRefCounted<ReceiveCompletion> {
|
||||
mutable Spinlock lock { LockRank::None };
|
||||
bool completed { false };
|
||||
const u16 tag;
|
||||
|
@ -6,9 +6,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/AtomicRefCounted.h>
|
||||
#include <AK/Error.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <AK/Types.h>
|
||||
@ -24,7 +24,7 @@ struct SysFSInodeData : public OpenFileDescriptionData {
|
||||
};
|
||||
|
||||
class SysFSDirectory;
|
||||
class SysFSComponent : public RefCounted<SysFSComponent> {
|
||||
class SysFSComponent : public AtomicRefCounted<SysFSComponent> {
|
||||
friend class SysFSDirectory;
|
||||
|
||||
public:
|
||||
|
@ -6,9 +6,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/Types.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <Kernel/PhysicalAddress.h>
|
||||
|
||||
namespace Kernel::ACPI {
|
||||
|
@ -6,16 +6,14 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Atomic.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/AtomicRefCounted.h>
|
||||
#include <Kernel/Locking/Spinlock.h>
|
||||
#include <Kernel/Memory/VMObject.h>
|
||||
#include <Kernel/Thread.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
class FutexQueue final
|
||||
: public RefCounted<FutexQueue>
|
||||
: public AtomicRefCounted<FutexQueue>
|
||||
, public Thread::BlockerSet {
|
||||
public:
|
||||
FutexQueue();
|
||||
|
@ -6,13 +6,13 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/AtomicRefCounted.h>
|
||||
#include <AK/Types.h>
|
||||
#include <Kernel/Graphics/GenericGraphicsAdapter.h>
|
||||
|
||||
namespace Kernel::Graphics {
|
||||
|
||||
class Console : public RefCounted<Console> {
|
||||
class Console : public AtomicRefCounted<Console> {
|
||||
public:
|
||||
// Stanadard VGA text mode colors
|
||||
enum Color : u8 {
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/Types.h>
|
||||
#include <Kernel/Graphics/Console/Console.h>
|
||||
#include <Kernel/PhysicalAddress.h>
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/Types.h>
|
||||
#include <Kernel/Graphics/Console/Console.h>
|
||||
#include <Kernel/Locking/Spinlock.h>
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
namespace Kernel {
|
||||
class GenericGraphicsAdapter
|
||||
: public RefCounted<GenericGraphicsAdapter>
|
||||
: public AtomicRefCounted<GenericGraphicsAdapter>
|
||||
, public Weakable<GenericGraphicsAdapter> {
|
||||
public:
|
||||
virtual ~GenericGraphicsAdapter() = default;
|
||||
|
@ -100,7 +100,7 @@ public:
|
||||
private:
|
||||
VirtIOGPU3DDevice(VirtIOGraphicsAdapter const& graphics_adapter, NonnullOwnPtr<Memory::Region> transfer_buffer_region);
|
||||
|
||||
class PerContextState : public RefCounted<PerContextState> {
|
||||
class PerContextState final : public AtomicRefCounted<PerContextState> {
|
||||
public:
|
||||
static ErrorOr<RefPtr<PerContextState>> try_create(Graphics::VirtIOGPU::ContextID context_id)
|
||||
{
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/AtomicRefCounted.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
@ -21,7 +21,7 @@ enum class LockType {
|
||||
};
|
||||
|
||||
template<typename T, LockType Lock>
|
||||
class ListedRefCounted : public RefCountedBase {
|
||||
class ListedRefCounted : public AtomicRefCountedBase {
|
||||
public:
|
||||
bool unref() const
|
||||
{
|
||||
|
@ -168,7 +168,7 @@ template<typename T>
|
||||
template<typename U>
|
||||
inline ErrorOr<WeakPtr<U>> Weakable<T>::try_make_weak_ptr() const
|
||||
{
|
||||
if constexpr (IsBaseOf<RefCountedBase, T>) {
|
||||
if constexpr (IsBaseOf<AtomicRefCountedBase, T>) {
|
||||
// Checking m_being_destroyed isn't sufficient when dealing with
|
||||
// a RefCounted type.The reference count will drop to 0 before the
|
||||
// destructor is invoked and revoke_weak_ptrs is called. So, try
|
||||
@ -192,7 +192,7 @@ inline ErrorOr<WeakPtr<U>> Weakable<T>::try_make_weak_ptr() const
|
||||
|
||||
WeakPtr<U> weak_ptr(m_link);
|
||||
|
||||
if constexpr (IsBaseOf<RefCountedBase, T>) {
|
||||
if constexpr (IsBaseOf<AtomicRefCountedBase, T>) {
|
||||
// Now drop the reference we temporarily added
|
||||
if (static_cast<const T*>(this)->unref()) {
|
||||
// We just dropped the last reference, which should have called
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
#include <AK/Assertions.h>
|
||||
#include <AK/Atomic.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/AtomicRefCounted.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/StdLibExtras.h>
|
||||
#include <Kernel/Arch/Processor.h>
|
||||
@ -21,7 +21,7 @@ class Weakable;
|
||||
template<typename T>
|
||||
class WeakPtr;
|
||||
|
||||
class WeakLink : public RefCounted<WeakLink> {
|
||||
class WeakLink final : public AtomicRefCounted<WeakLink> {
|
||||
template<typename T>
|
||||
friend class Weakable;
|
||||
template<typename T>
|
||||
@ -30,7 +30,7 @@ class WeakLink : public RefCounted<WeakLink> {
|
||||
public:
|
||||
template<typename T, typename PtrTraits = RefPtrTraits<T>>
|
||||
RefPtr<T, PtrTraits> strong_ref() const
|
||||
requires(IsBaseOf<RefCountedBase, T>)
|
||||
requires(IsBaseOf<AtomicRefCountedBase, T>)
|
||||
{
|
||||
RefPtr<T, PtrTraits> ref;
|
||||
|
||||
|
@ -63,7 +63,7 @@ private:
|
||||
Bitmap m_cow_map;
|
||||
|
||||
// AnonymousVMObject shares committed COW pages with cloned children (happens on fork)
|
||||
class SharedCommittedCowPages : public RefCounted<SharedCommittedCowPages> {
|
||||
class SharedCommittedCowPages final : public AtomicRefCounted<SharedCommittedCowPages> {
|
||||
AK_MAKE_NONCOPYABLE(SharedCommittedCowPages);
|
||||
|
||||
public:
|
||||
|
@ -6,10 +6,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/AtomicRefCounted.h>
|
||||
#include <AK/Badge.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/IntrusiveRedBlackTree.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <Kernel/Forward.h>
|
||||
#include <Kernel/Locking/Spinlock.h>
|
||||
@ -17,7 +17,7 @@
|
||||
|
||||
namespace Kernel::Memory {
|
||||
|
||||
class PageDirectory : public RefCounted<PageDirectory> {
|
||||
class PageDirectory final : public AtomicRefCounted<PageDirectory> {
|
||||
friend class MemoryManager;
|
||||
|
||||
public:
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/AtomicRefCounted.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <Kernel/Devices/BlockDevice.h>
|
||||
#include <Kernel/Memory/AnonymousVMObject.h>
|
||||
@ -16,7 +17,7 @@ namespace Kernel::Memory {
|
||||
|
||||
// A Scatter-Gather List type that owns its buffers
|
||||
|
||||
class ScatterGatherList : public RefCounted<ScatterGatherList> {
|
||||
class ScatterGatherList final : public AtomicRefCounted<ScatterGatherList> {
|
||||
public:
|
||||
static RefPtr<ScatterGatherList> try_create(AsyncBlockDeviceRequest&, Span<NonnullRefPtr<PhysicalPage>> allocated_pages, size_t device_block_size);
|
||||
VMObject const& vmobject() const { return m_vm_object; }
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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>
|
||||
|
@ -6,9 +6,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/AtomicRefCounted.h>
|
||||
#include <AK/Error.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/Types.h>
|
||||
#include <Kernel/FileSystem/File.h>
|
||||
@ -66,7 +66,7 @@ private:
|
||||
NonnullRefPtr<ProcFSRootDirectory> m_root_directory;
|
||||
};
|
||||
|
||||
class ProcFSExposedComponent : public RefCounted<ProcFSExposedComponent> {
|
||||
class ProcFSExposedComponent : public AtomicRefCounted<ProcFSExposedComponent> {
|
||||
public:
|
||||
StringView name() const { return m_name->view(); }
|
||||
virtual ErrorOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer&, OpenFileDescription*) const { VERIFY_NOT_REACHED(); }
|
||||
|
@ -6,8 +6,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/AtomicRefCounted.h>
|
||||
#include <AK/IntrusiveList.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/Weakable.h>
|
||||
#include <Kernel/Locking/SpinlockProtected.h>
|
||||
#include <Kernel/UnixTypes.h>
|
||||
@ -15,7 +15,7 @@
|
||||
namespace Kernel {
|
||||
|
||||
class ProcessGroup
|
||||
: public RefCounted<ProcessGroup>
|
||||
: public AtomicRefCounted<ProcessGroup>
|
||||
, public Weakable<ProcessGroup> {
|
||||
|
||||
AK_MAKE_NONMOVABLE(ProcessGroup);
|
||||
|
@ -32,7 +32,7 @@ class AsyncBlockDeviceRequest;
|
||||
|
||||
class AHCIInterruptHandler;
|
||||
class AHCIPort
|
||||
: public RefCounted<AHCIPort>
|
||||
: public AtomicRefCounted<AHCIPort>
|
||||
, public Weakable<AHCIPort> {
|
||||
friend class AHCIController;
|
||||
|
||||
|
@ -13,7 +13,7 @@ namespace Kernel {
|
||||
class AsyncBlockDeviceRequest;
|
||||
|
||||
class ATAPort
|
||||
: public RefCounted<ATAPort>
|
||||
: public AtomicRefCounted<ATAPort>
|
||||
, public Weakable<ATAPort> {
|
||||
|
||||
friend class ATAPortInterruptDisabler;
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <AK/NonnullRefPtrVector.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/Types.h>
|
||||
#include <Kernel/Locking/Spinlock.h>
|
||||
|
@ -6,10 +6,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/AtomicRefCounted.h>
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <AK/NonnullRefPtrVector.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/Types.h>
|
||||
#include <Kernel/Bus/PCI/Device.h>
|
||||
@ -27,9 +27,9 @@ struct DoorbellRegister {
|
||||
};
|
||||
|
||||
class AsyncBlockDeviceRequest;
|
||||
class NVMeQueue : public RefCounted<NVMeQueue> {
|
||||
class NVMeQueue : public AtomicRefCounted<NVMeQueue> {
|
||||
public:
|
||||
static ErrorOr<NonnullRefPtr<NVMeQueue>> try_create(u16 qid, Optional<u8> irq, u32 q_depth, OwnPtr<Memory::Region> cq_dma_region, NonnullRefPtrVector<Memory::PhysicalPage> cq_dma_page, OwnPtr<Memory::Region> sq_dma_region, NonnullRefPtrVector<Memory::PhysicalPage> sq_dma_page, Memory::TypedMapping<volatile DoorbellRegister> db_regs);
|
||||
static ErrorOr<NonnullRefPtr<NVMeQueue>> try_create(u16 qid, Optional<u8> irq, u32 q_depth, OwnPtr<Memory::Region> cq_dma_region, NonnullRefPtrVector<Memory::PhysicalPage> cq_dma_page, OwnPtr<Memory::Region> sq_dma_region, NonnullRefPtrVector<Memory::PhysicalPage> sq_dma_page, Memory::TypedMapping<DoorbellRegister volatile> db_regs);
|
||||
bool is_admin_queue() { return m_admin_queue; };
|
||||
u16 submit_sync_sqe(NVMeSubmission&);
|
||||
void read(AsyncBlockDeviceRequest& request, u16 nsid, u64 index, u32 count);
|
||||
@ -43,7 +43,7 @@ protected:
|
||||
{
|
||||
m_db_regs->sq_tail = m_sq_tail;
|
||||
}
|
||||
NVMeQueue(NonnullOwnPtr<Memory::Region> rw_dma_region, Memory::PhysicalPage const& rw_dma_page, u16 qid, u32 q_depth, OwnPtr<Memory::Region> cq_dma_region, NonnullRefPtrVector<Memory::PhysicalPage> cq_dma_page, OwnPtr<Memory::Region> sq_dma_region, NonnullRefPtrVector<Memory::PhysicalPage> sq_dma_page, Memory::TypedMapping<volatile DoorbellRegister> db_regs);
|
||||
NVMeQueue(NonnullOwnPtr<Memory::Region> rw_dma_region, Memory::PhysicalPage const& rw_dma_page, u16 qid, u32 q_depth, OwnPtr<Memory::Region> cq_dma_region, NonnullRefPtrVector<Memory::PhysicalPage> cq_dma_page, OwnPtr<Memory::Region> sq_dma_region, NonnullRefPtrVector<Memory::PhysicalPage> sq_dma_page, Memory::TypedMapping<DoorbellRegister volatile> db_regs);
|
||||
|
||||
private:
|
||||
bool cqe_available();
|
||||
@ -75,7 +75,7 @@ private:
|
||||
OwnPtr<Memory::Region> m_sq_dma_region;
|
||||
NonnullRefPtrVector<Memory::PhysicalPage> m_sq_dma_page;
|
||||
Span<NVMeCompletion> m_cqe_array;
|
||||
Memory::TypedMapping<volatile DoorbellRegister> m_db_regs;
|
||||
Memory::TypedMapping<DoorbellRegister volatile> m_db_regs;
|
||||
NonnullRefPtr<Memory::PhysicalPage> m_rw_dma_page;
|
||||
};
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ namespace Kernel {
|
||||
|
||||
class AsyncBlockDeviceRequest;
|
||||
class StorageDevice;
|
||||
class StorageController : public RefCounted<StorageController> {
|
||||
class StorageController : public AtomicRefCounted<StorageController> {
|
||||
|
||||
public:
|
||||
virtual ~StorageController() = default;
|
||||
|
@ -6,8 +6,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/AtomicRefCounted.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <Kernel/Interrupts/IRQHandler.h>
|
||||
#include <Kernel/Time/TimeManagement.h>
|
||||
|
||||
@ -23,8 +23,7 @@ enum class HardwareTimerType {
|
||||
template<typename InterruptHandlerType>
|
||||
class HardwareTimer;
|
||||
|
||||
class HardwareTimerBase
|
||||
: public RefCounted<HardwareTimerBase> {
|
||||
class HardwareTimerBase : public AtomicRefCounted<HardwareTimerBase> {
|
||||
public:
|
||||
virtual ~HardwareTimerBase() = default;
|
||||
|
||||
|
@ -6,11 +6,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/AtomicRefCounted.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/IntrusiveList.h>
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/Time.h>
|
||||
#include <Kernel/Time/TimeManagement.h>
|
||||
|
||||
@ -18,7 +18,7 @@ namespace Kernel {
|
||||
|
||||
AK_TYPEDEF_DISTINCT_ORDERED_ID(u64, TimerId);
|
||||
|
||||
class Timer : public RefCounted<Timer> {
|
||||
class Timer final : public AtomicRefCounted<Timer> {
|
||||
friend class TimerQueue;
|
||||
|
||||
public:
|
||||
|
Loading…
Reference in New Issue
Block a user