mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 22:17:42 +00:00
Kernel: Rename File::{before_removing => will_be_destroyed}
This will allow File and it's descendants to use RefCounted instead of having a custom implementation of unref. (Since RefCounted calls will_be_destroyed automatically) This commit also removes an erroneous call to `before_removing` in AHCIPort, this is a duplicate call, as the only reference to the device is immediately dropped following the call, which in turns calls `before_removing` via File::unref.
This commit is contained in:
parent
d7ec5d042f
commit
4a3a947df3
6 changed files with 5 additions and 6 deletions
|
@ -131,7 +131,7 @@ void Device::after_inserting()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Device::before_removing()
|
void Device::will_be_destroyed()
|
||||||
{
|
{
|
||||||
VERIFY(m_sysfs_component);
|
VERIFY(m_sysfs_component);
|
||||||
SysFSComponentRegistry::the().devices_list().with_exclusive([&](auto& list) -> void {
|
SysFSComponentRegistry::the().devices_list().with_exclusive([&](auto& list) -> void {
|
||||||
|
|
|
@ -47,7 +47,7 @@ public:
|
||||||
GroupID gid() const { return m_gid; }
|
GroupID gid() const { return m_gid; }
|
||||||
|
|
||||||
virtual bool is_device() const override { return true; }
|
virtual bool is_device() const override { return true; }
|
||||||
virtual void before_removing() override;
|
virtual void will_be_destroyed() override;
|
||||||
virtual void after_inserting();
|
virtual void after_inserting();
|
||||||
void process_next_queued_request(Badge<AsyncDeviceRequest>, const AsyncDeviceRequest&);
|
void process_next_queued_request(Badge<AsyncDeviceRequest>, const AsyncDeviceRequest&);
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ bool File::unref() const
|
||||||
{
|
{
|
||||||
if (deref_base())
|
if (deref_base())
|
||||||
return false;
|
return false;
|
||||||
const_cast<File&>(*this).before_removing();
|
const_cast<File&>(*this).will_be_destroyed();
|
||||||
delete this;
|
delete this;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ class File
|
||||||
, public Weakable<File> {
|
, public Weakable<File> {
|
||||||
public:
|
public:
|
||||||
virtual bool unref() const;
|
virtual bool unref() const;
|
||||||
virtual void before_removing() { }
|
virtual void will_be_destroyed() { }
|
||||||
virtual ~File();
|
virtual ~File();
|
||||||
|
|
||||||
virtual ErrorOr<NonnullRefPtr<OpenFileDescription>> open(int options);
|
virtual ErrorOr<NonnullRefPtr<OpenFileDescription>> open(int options);
|
||||||
|
|
|
@ -77,7 +77,6 @@ void AHCIPort::handle_interrupt()
|
||||||
m_connected_device->prepare_for_unplug();
|
m_connected_device->prepare_for_unplug();
|
||||||
StorageManagement::the().remove_device(*m_connected_device);
|
StorageManagement::the().remove_device(*m_connected_device);
|
||||||
g_io_work->queue([this]() {
|
g_io_work->queue([this]() {
|
||||||
m_connected_device->before_removing();
|
|
||||||
m_connected_device.clear();
|
m_connected_device.clear();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -29,7 +29,7 @@ bool SlavePTY::unref() const
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
if (did_hit_zero) {
|
if (did_hit_zero) {
|
||||||
const_cast<SlavePTY&>(*this).before_removing();
|
const_cast<SlavePTY&>(*this).will_be_destroyed();
|
||||||
delete this;
|
delete this;
|
||||||
}
|
}
|
||||||
return did_hit_zero;
|
return did_hit_zero;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue