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

AK+Everywhere: Reduce the number of template parameters of IntrusiveList

This makes the user-facing type only take the node member pointer, and
lets the compiler figure out the other needed types from that.
This commit is contained in:
Ali Mohammad Pur 2021-09-09 16:30:59 +04:30 committed by Idan Horowitz
parent 93cf01ad7d
commit 5a0cdb15b0
41 changed files with 111 additions and 92 deletions

View file

@ -54,7 +54,7 @@ private:
RefPtr<SysFSUSBDeviceInformation> device_node_for(USB::Device& device);
IntrusiveList<SysFSUSBDeviceInformation, RefPtr<SysFSUSBDeviceInformation>, &SysFSUSBDeviceInformation::m_list_node> m_device_nodes;
IntrusiveList<&SysFSUSBDeviceInformation::m_list_node> m_device_nodes;
mutable Spinlock m_lock;
};

View file

@ -33,7 +33,7 @@ private:
IntrusiveListNode<USBController, NonnullRefPtr<USBController>> m_controller_list_node;
public:
using List = IntrusiveList<USBController, NonnullRefPtr<USBController>, &USBController::m_controller_list_node>;
using List = IntrusiveList<&USBController::m_controller_list_node>;
};
}

View file

@ -64,6 +64,6 @@ private:
IntrusiveListNode<Device, NonnullRefPtr<Device>> m_hub_child_node;
public:
using List = IntrusiveList<Device, NonnullRefPtr<Device>, &Device::m_hub_child_node>;
using List = IntrusiveList<&Device::m_hub_child_node>;
};
}

View file

@ -143,7 +143,7 @@ private:
RequestResult m_result { Pending };
IntrusiveListNode<AsyncDeviceRequest, RefPtr<AsyncDeviceRequest>> m_list_node;
using AsyncDeviceSubRequestList = IntrusiveList<AsyncDeviceRequest, RefPtr<AsyncDeviceRequest>, &AsyncDeviceRequest::m_list_node>;
using AsyncDeviceSubRequestList = IntrusiveList<&AsyncDeviceRequest::m_list_node>;
AsyncDeviceSubRequestList m_sub_requests_pending;
AsyncDeviceSubRequestList m_sub_requests_complete;

View file

@ -97,8 +97,8 @@ public:
private:
BlockBasedFileSystem& m_fs;
mutable HashMap<BlockBasedFileSystem::BlockIndex, CacheEntry*> m_hash;
mutable IntrusiveList<CacheEntry, RawPtr<CacheEntry>, &CacheEntry::list_node> m_clean_list;
mutable IntrusiveList<CacheEntry, RawPtr<CacheEntry>, &CacheEntry::list_node> m_dirty_list;
mutable IntrusiveList<&CacheEntry::list_node> m_clean_list;
mutable IntrusiveList<&CacheEntry::list_node> m_dirty_list;
NonnullOwnPtr<KBuffer> m_cached_block_data;
NonnullOwnPtr<KBuffer> m_entries;
bool m_dirty { false };

View file

@ -50,7 +50,7 @@ private:
mutable IntrusiveListNode<Custody> m_all_custodies_list_node;
public:
using AllCustodiesList = IntrusiveList<Custody, RawPtr<Custody>, &Custody::m_all_custodies_list_node>;
using AllCustodiesList = IntrusiveList<&Custody::m_all_custodies_list_node>;
};
}

View file

@ -143,7 +143,7 @@ protected:
DevTmpFSDirectoryInode(DevTmpFS&, NonnullOwnPtr<KString> name);
// ^Inode
OwnPtr<KString> m_name;
IntrusiveList<DevTmpFSInode, NonnullRefPtr<DevTmpFSInode>, &DevTmpFSInode::m_list_node> m_nodes;
IntrusiveList<&DevTmpFSInode::m_list_node> m_nodes;
private:
explicit DevTmpFSDirectoryInode(DevTmpFS&);

View file

@ -134,7 +134,7 @@ private:
Vector<Flock> m_flocks;
public:
using AllInstancesList = IntrusiveList<Inode, RawPtr<Inode>, &Inode::m_inode_list_node>;
using AllInstancesList = IntrusiveList<&Inode::m_inode_list_node>;
static SpinlockProtected<Inode::AllInstancesList>& all_instances();
};

View file

@ -81,7 +81,7 @@ private:
};
class SysFSComponentRegistry {
using DevicesList = MutexProtected<IntrusiveList<SysFSDeviceComponent, NonnullRefPtr<SysFSDeviceComponent>, &SysFSDeviceComponent::m_list_node>>;
using DevicesList = MutexProtected<IntrusiveList<&SysFSDeviceComponent::m_list_node>>;
public:
static SysFSComponentRegistry& the();

View file

@ -79,7 +79,7 @@ private:
NonnullOwnPtr<KString> name;
NonnullRefPtr<TmpFSInode> inode;
IntrusiveListNode<Child> list_node {};
using List = IntrusiveList<Child, RawPtr<Child>, &Child::list_node>;
using List = IntrusiveList<&Child::list_node>;
};
Child* find_child_by_name(StringView);

View file

@ -68,6 +68,6 @@ private:
IntrusiveListNode<GenericInterruptHandler> m_list_node;
public:
using List = IntrusiveList<GenericInterruptHandler, RawPtr<GenericInterruptHandler>, &GenericInterruptHandler::m_list_node>;
using List = IntrusiveList<&GenericInterruptHandler::m_list_node>;
};
}

View file

@ -69,7 +69,7 @@ public:
}
private:
using BlockedThreadList = IntrusiveList<Thread, RawPtr<Thread>, &Thread::m_blocked_threads_list_node>;
using BlockedThreadList = IntrusiveList<&Thread::m_blocked_threads_list_node>;
ALWAYS_INLINE BlockedThreadList& thread_list_for_mode(Mode mode)
{

View file

@ -89,7 +89,7 @@ private:
IntrusiveListNode<PhysicalZone> m_list_node;
public:
using List = IntrusiveList<PhysicalZone, RawPtr<PhysicalZone>, &PhysicalZone::m_list_node>;
using List = IntrusiveList<&PhysicalZone::m_list_node>;
};
}

View file

@ -217,8 +217,8 @@ private:
IntrusiveListNode<Region> m_vmobject_list_node;
public:
using ListInMemoryManager = IntrusiveList<Region, RawPtr<Region>, &Region::m_memory_manager_list_node>;
using ListInVMObject = IntrusiveList<Region, RawPtr<Region>, &Region::m_vmobject_list_node>;
using ListInMemoryManager = IntrusiveList<&Region::m_memory_manager_list_node>;
using ListInVMObject = IntrusiveList<&Region::m_vmobject_list_node>;
};
AK_ENUM_BITWISE_OPERATORS(Region::Access)

View file

@ -73,7 +73,7 @@ private:
Region::ListInVMObject m_regions;
public:
using AllInstancesList = IntrusiveList<VMObject, RawPtr<VMObject>, &VMObject::m_list_node>;
using AllInstancesList = IntrusiveList<&VMObject::m_list_node>;
static SpinlockProtected<VMObject::AllInstancesList>& all_instances();
};

View file

@ -133,7 +133,7 @@ private:
IntrusiveListNode<IPv4Socket> m_list_node;
public:
using List = IntrusiveList<IPv4Socket, RawPtr<IPv4Socket>, &IPv4Socket::m_list_node>;
using List = IntrusiveList<&IPv4Socket::m_list_node>;
static MutexProtected<IPv4Socket::List>& all_sockets();
};

View file

@ -105,7 +105,7 @@ private:
IntrusiveListNode<LocalSocket> m_list_node;
public:
using List = IntrusiveList<LocalSocket, RawPtr<LocalSocket>, &LocalSocket::m_list_node>;
using List = IntrusiveList<&LocalSocket::m_list_node>;
};
}

View file

@ -111,7 +111,7 @@ private:
// FIXME: Make this configurable
static constexpr size_t max_packet_buffers = 1024;
using PacketList = IntrusiveList<PacketWithTimestamp, RefPtr<PacketWithTimestamp>, &PacketWithTimestamp::packet_node>;
using PacketList = IntrusiveList<&PacketWithTimestamp::packet_node>;
PacketList m_packet_queue;
size_t m_packet_queue_size { 0 };

View file

@ -225,7 +225,7 @@ private:
IntrusiveListNode<TCPSocket> m_retransmit_list_node;
public:
using RetransmitList = IntrusiveList<TCPSocket, RawPtr<TCPSocket>, &TCPSocket::m_retransmit_list_node>;
using RetransmitList = IntrusiveList<&TCPSocket::m_retransmit_list_node>;
static MutexProtected<TCPSocket::RetransmitList>& sockets_for_retransmit();
};

View file

@ -807,7 +807,7 @@ private:
u8 m_protected_values_padding[PAGE_SIZE - sizeof(ProtectedValues)];
public:
using List = IntrusiveListRelaxedConst<Process, RawPtr<Process>, &Process::m_list_node>;
using List = IntrusiveListRelaxedConst<&Process::m_list_node>;
};
// Note: Process object should be 2 pages of 4096 bytes each.

View file

@ -40,7 +40,7 @@ private:
ProcessGroupID m_pgid;
public:
using List = IntrusiveList<ProcessGroup, RawPtr<ProcessGroup>, &ProcessGroup::m_list_node>;
using List = IntrusiveList<&ProcessGroup::m_list_node>;
};
SpinlockProtected<ProcessGroup::List>& process_groups();

View file

@ -38,7 +38,7 @@ Atomic<bool> g_finalizer_has_work { false };
READONLY_AFTER_INIT static Process* s_colonel_process;
struct ThreadReadyQueue {
IntrusiveList<Thread, RawPtr<Thread>, &Thread::m_ready_queue_node> thread_list;
IntrusiveList<&Thread::m_ready_queue_node> thread_list;
};
struct ThreadReadyQueues {

View file

@ -51,7 +51,7 @@ private:
String m_boot_argument;
WeakPtr<BlockDevice> m_boot_block_device;
NonnullRefPtrVector<StorageController> m_controllers;
IntrusiveList<StorageDevice, RefPtr<StorageDevice>, &StorageDevice::m_list_node> m_storage_devices;
IntrusiveList<&StorageDevice::m_list_node> m_storage_devices;
};
}

View file

@ -49,7 +49,7 @@ private:
mutable IntrusiveListNode<SlavePTY> m_list_node;
public:
using List = IntrusiveList<SlavePTY, RawPtr<SlavePTY>, &SlavePTY::m_list_node>;
using List = IntrusiveList<&SlavePTY::m_list_node>;
static SpinlockProtected<SlavePTY::List>& all_instances();
};

View file

@ -1372,8 +1372,8 @@ private:
mutable IntrusiveListNode<Thread> m_global_thread_list_node;
public:
using ListInProcess = IntrusiveList<Thread, RawPtr<Thread>, &Thread::m_process_thread_list_node>;
using GlobalList = IntrusiveList<Thread, RawPtr<Thread>, &Thread::m_global_thread_list_node>;
using ListInProcess = IntrusiveList<&Thread::m_process_thread_list_node>;
using GlobalList = IntrusiveList<&Thread::m_global_thread_list_node>;
static SpinlockProtected<GlobalList>& all_instances();
};

View file

@ -77,7 +77,7 @@ private:
public:
IntrusiveListNode<Timer> m_list_node;
using List = IntrusiveList<Timer, RawPtr<Timer>, &Timer::m_list_node>;
using List = IntrusiveList<&Timer::m_list_node>;
};
class TimerQueue {

View file

@ -51,7 +51,7 @@ private:
RefPtr<Thread> m_thread;
WaitQueue m_wait_queue;
IntrusiveList<WorkItem, RawPtr<WorkItem>, &WorkItem::m_node> m_items;
IntrusiveList<&WorkItem::m_node> m_items;
Spinlock m_lock;
};