mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 03:47:34 +00:00
Kernel: Make self-contained locking smart pointers their own classes
Until now, our kernel has reimplemented a number of AK classes to provide automatic internal locking: - RefPtr - NonnullRefPtr - WeakPtr - Weakable This patch renames the Kernel classes so that they can coexist with the original AK classes: - RefPtr => LockRefPtr - NonnullRefPtr => NonnullLockRefPtr - WeakPtr => LockWeakPtr - Weakable => LockWeakable The goal here is to eventually get rid of the Lock* classes in favor of using external locking.
This commit is contained in:
parent
e475263113
commit
11eee67b85
360 changed files with 1703 additions and 1672 deletions
|
@ -12,9 +12,9 @@ namespace Kernel {
|
|||
|
||||
static SysFSBlockDevicesDirectory* s_the { nullptr };
|
||||
|
||||
NonnullRefPtr<SysFSBlockDevicesDirectory> SysFSBlockDevicesDirectory::must_create(SysFSDeviceIdentifiersDirectory const& devices_directory)
|
||||
NonnullLockRefPtr<SysFSBlockDevicesDirectory> SysFSBlockDevicesDirectory::must_create(SysFSDeviceIdentifiersDirectory const& devices_directory)
|
||||
{
|
||||
return adopt_ref_if_nonnull(new SysFSBlockDevicesDirectory(devices_directory)).release_nonnull();
|
||||
return adopt_lock_ref_if_nonnull(new SysFSBlockDevicesDirectory(devices_directory)).release_nonnull();
|
||||
}
|
||||
SysFSBlockDevicesDirectory::SysFSBlockDevicesDirectory(SysFSDeviceIdentifiersDirectory const& devices_directory)
|
||||
: SysFSDirectory(devices_directory)
|
||||
|
|
|
@ -17,7 +17,7 @@ class SysFSBlockDevicesDirectory final : public SysFSDirectory {
|
|||
|
||||
public:
|
||||
virtual StringView name() const override { return "block"sv; }
|
||||
static NonnullRefPtr<SysFSBlockDevicesDirectory> must_create(SysFSDeviceIdentifiersDirectory const&);
|
||||
static NonnullLockRefPtr<SysFSBlockDevicesDirectory> must_create(SysFSDeviceIdentifiersDirectory const&);
|
||||
|
||||
static SysFSBlockDevicesDirectory& the();
|
||||
|
||||
|
|
|
@ -12,9 +12,9 @@ namespace Kernel {
|
|||
|
||||
static SysFSCharacterDevicesDirectory* s_the { nullptr };
|
||||
|
||||
NonnullRefPtr<SysFSCharacterDevicesDirectory> SysFSCharacterDevicesDirectory::must_create(SysFSDeviceIdentifiersDirectory const& devices_directory)
|
||||
NonnullLockRefPtr<SysFSCharacterDevicesDirectory> SysFSCharacterDevicesDirectory::must_create(SysFSDeviceIdentifiersDirectory const& devices_directory)
|
||||
{
|
||||
return adopt_ref_if_nonnull(new SysFSCharacterDevicesDirectory(devices_directory)).release_nonnull();
|
||||
return adopt_lock_ref_if_nonnull(new SysFSCharacterDevicesDirectory(devices_directory)).release_nonnull();
|
||||
}
|
||||
SysFSCharacterDevicesDirectory::SysFSCharacterDevicesDirectory(SysFSDeviceIdentifiersDirectory const& devices_directory)
|
||||
: SysFSDirectory(devices_directory)
|
||||
|
|
|
@ -17,7 +17,7 @@ class SysFSCharacterDevicesDirectory final : public SysFSDirectory {
|
|||
|
||||
public:
|
||||
virtual StringView name() const override { return "char"sv; }
|
||||
static NonnullRefPtr<SysFSCharacterDevicesDirectory> must_create(SysFSDeviceIdentifiersDirectory const&);
|
||||
static NonnullLockRefPtr<SysFSCharacterDevicesDirectory> must_create(SysFSDeviceIdentifiersDirectory const&);
|
||||
|
||||
static SysFSCharacterDevicesDirectory& the();
|
||||
|
||||
|
|
|
@ -10,11 +10,11 @@
|
|||
|
||||
namespace Kernel {
|
||||
|
||||
NonnullRefPtr<SysFSDeviceComponent> SysFSDeviceComponent::must_create(Device const& device)
|
||||
NonnullLockRefPtr<SysFSDeviceComponent> SysFSDeviceComponent::must_create(Device const& device)
|
||||
{
|
||||
// FIXME: Handle allocation failure gracefully
|
||||
auto device_name = MUST(KString::formatted("{}:{}", device.major(), device.minor()));
|
||||
return adopt_ref_if_nonnull(new SysFSDeviceComponent(move(device_name), device)).release_nonnull();
|
||||
return adopt_lock_ref_if_nonnull(new SysFSDeviceComponent(move(device_name), device)).release_nonnull();
|
||||
}
|
||||
SysFSDeviceComponent::SysFSDeviceComponent(NonnullOwnPtr<KString> major_minor_formatted_device_name, Device const& device)
|
||||
: SysFSComponent()
|
||||
|
|
|
@ -14,12 +14,12 @@ namespace Kernel {
|
|||
|
||||
class SysFSDeviceComponent final
|
||||
: public SysFSComponent
|
||||
, public Weakable<SysFSDeviceComponent> {
|
||||
, public LockWeakable<SysFSDeviceComponent> {
|
||||
friend class SysFSBlockDevicesDirectory;
|
||||
friend class SysFSCharacterDevicesDirectory;
|
||||
|
||||
public:
|
||||
static NonnullRefPtr<SysFSDeviceComponent> must_create(Device const&);
|
||||
static NonnullLockRefPtr<SysFSDeviceComponent> must_create(Device const&);
|
||||
virtual StringView name() const override { return m_major_minor_formatted_device_name->view(); }
|
||||
bool is_block_device() const { return m_block_device; }
|
||||
|
||||
|
|
|
@ -20,9 +20,9 @@ SysFSDeviceIdentifiersDirectory& SysFSDeviceIdentifiersDirectory::the()
|
|||
return *s_the;
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT NonnullRefPtr<SysFSDeviceIdentifiersDirectory> SysFSDeviceIdentifiersDirectory::must_create(SysFSRootDirectory const& root_directory)
|
||||
UNMAP_AFTER_INIT NonnullLockRefPtr<SysFSDeviceIdentifiersDirectory> SysFSDeviceIdentifiersDirectory::must_create(SysFSRootDirectory const& root_directory)
|
||||
{
|
||||
auto devices_directory = adopt_ref_if_nonnull(new SysFSDeviceIdentifiersDirectory(root_directory)).release_nonnull();
|
||||
auto devices_directory = adopt_lock_ref_if_nonnull(new SysFSDeviceIdentifiersDirectory(root_directory)).release_nonnull();
|
||||
MUST(devices_directory->m_child_components.with([&](auto& list) -> ErrorOr<void> {
|
||||
list.append(SysFSBlockDevicesDirectory::must_create(*devices_directory));
|
||||
list.append(SysFSCharacterDevicesDirectory::must_create(*devices_directory));
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace Kernel {
|
|||
class SysFSDeviceIdentifiersDirectory final : public SysFSDirectory {
|
||||
public:
|
||||
virtual StringView name() const override { return "dev"sv; }
|
||||
static NonnullRefPtr<SysFSDeviceIdentifiersDirectory> must_create(SysFSRootDirectory const&);
|
||||
static NonnullLockRefPtr<SysFSDeviceIdentifiersDirectory> must_create(SysFSRootDirectory const&);
|
||||
|
||||
static SysFSDeviceIdentifiersDirectory& the();
|
||||
|
||||
|
|
|
@ -11,16 +11,16 @@
|
|||
|
||||
namespace Kernel {
|
||||
|
||||
ErrorOr<NonnullRefPtr<SysFSSymbolicLinkDeviceComponent>> SysFSSymbolicLinkDeviceComponent::try_create(SysFSCharacterDevicesDirectory const& parent_directory, Device const& device, SysFSComponent const& pointed_component)
|
||||
ErrorOr<NonnullLockRefPtr<SysFSSymbolicLinkDeviceComponent>> SysFSSymbolicLinkDeviceComponent::try_create(SysFSCharacterDevicesDirectory const& parent_directory, Device const& device, SysFSComponent const& pointed_component)
|
||||
{
|
||||
auto device_name = TRY(KString::formatted("{}:{}", device.major(), device.minor()));
|
||||
return adopt_nonnull_ref_or_enomem(new (nothrow) SysFSSymbolicLinkDeviceComponent(parent_directory, move(device_name), device, pointed_component));
|
||||
return adopt_nonnull_lock_ref_or_enomem(new (nothrow) SysFSSymbolicLinkDeviceComponent(parent_directory, move(device_name), device, pointed_component));
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<SysFSSymbolicLinkDeviceComponent>> SysFSSymbolicLinkDeviceComponent::try_create(SysFSBlockDevicesDirectory const& parent_directory, Device const& device, SysFSComponent const& pointed_component)
|
||||
ErrorOr<NonnullLockRefPtr<SysFSSymbolicLinkDeviceComponent>> SysFSSymbolicLinkDeviceComponent::try_create(SysFSBlockDevicesDirectory const& parent_directory, Device const& device, SysFSComponent const& pointed_component)
|
||||
{
|
||||
auto device_name = TRY(KString::formatted("{}:{}", device.major(), device.minor()));
|
||||
return adopt_nonnull_ref_or_enomem(new (nothrow) SysFSSymbolicLinkDeviceComponent(parent_directory, move(device_name), device, pointed_component));
|
||||
return adopt_nonnull_lock_ref_or_enomem(new (nothrow) SysFSSymbolicLinkDeviceComponent(parent_directory, move(device_name), device, pointed_component));
|
||||
}
|
||||
|
||||
SysFSSymbolicLinkDeviceComponent::SysFSSymbolicLinkDeviceComponent(SysFSCharacterDevicesDirectory const& parent_directory, NonnullOwnPtr<KString> major_minor_formatted_device_name, Device const& device, SysFSComponent const& pointed_component)
|
||||
|
|
|
@ -17,12 +17,12 @@ namespace Kernel {
|
|||
class SysFSDeviceIdentifiersDirectory;
|
||||
class SysFSSymbolicLinkDeviceComponent final
|
||||
: public SysFSSymbolicLink
|
||||
, public Weakable<SysFSSymbolicLinkDeviceComponent> {
|
||||
, public LockWeakable<SysFSSymbolicLinkDeviceComponent> {
|
||||
friend class SysFSComponentRegistry;
|
||||
|
||||
public:
|
||||
static ErrorOr<NonnullRefPtr<SysFSSymbolicLinkDeviceComponent>> try_create(SysFSCharacterDevicesDirectory const& parent_directory, Device const& device, SysFSComponent const& pointed_component);
|
||||
static ErrorOr<NonnullRefPtr<SysFSSymbolicLinkDeviceComponent>> try_create(SysFSBlockDevicesDirectory const& parent_directory, Device const& device, SysFSComponent const& pointed_component);
|
||||
static ErrorOr<NonnullLockRefPtr<SysFSSymbolicLinkDeviceComponent>> try_create(SysFSCharacterDevicesDirectory const& parent_directory, Device const& device, SysFSComponent const& pointed_component);
|
||||
static ErrorOr<NonnullLockRefPtr<SysFSSymbolicLinkDeviceComponent>> try_create(SysFSBlockDevicesDirectory const& parent_directory, Device const& device, SysFSComponent const& pointed_component);
|
||||
|
||||
virtual StringView name() const override { return m_major_minor_formatted_device_name->view(); }
|
||||
bool is_block_device() const { return m_block_device; }
|
||||
|
@ -31,7 +31,7 @@ private:
|
|||
SysFSSymbolicLinkDeviceComponent(SysFSCharacterDevicesDirectory const& parent_directory, NonnullOwnPtr<KString> major_minor_formatted_device_name, Device const&, SysFSComponent const& pointed_component);
|
||||
SysFSSymbolicLinkDeviceComponent(SysFSBlockDevicesDirectory const& parent_directory, NonnullOwnPtr<KString> major_minor_formatted_device_name, Device const&, SysFSComponent const& pointed_component);
|
||||
|
||||
IntrusiveListNode<SysFSSymbolicLinkDeviceComponent, NonnullRefPtr<SysFSSymbolicLinkDeviceComponent>> m_list_node;
|
||||
IntrusiveListNode<SysFSSymbolicLinkDeviceComponent, NonnullLockRefPtr<SysFSSymbolicLinkDeviceComponent>> m_list_node;
|
||||
bool const m_block_device { false };
|
||||
NonnullOwnPtr<KString> m_major_minor_formatted_device_name;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue