mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-08 04:15:23 +03:00
Kernel: Port File to RefCounted
Since RefCounted automatically calls a method named `will_be_destoyed` on classes that have one, so there's no need to have a custom implementation of unref in File.
This commit is contained in:
parent
4a3a947df3
commit
6e2a82df13
Notes:
sideshowbarker
2024-07-18 04:38:32 +09:00
Author: https://github.com/IdanHo Commit: https://github.com/SerenityOS/serenity/commit/6e2a82df134 Pull-request: https://github.com/SerenityOS/serenity/pull/11474 Reviewed-by: https://github.com/bgianfo ✅
@ -20,15 +20,6 @@ File::~File()
|
||||
{
|
||||
}
|
||||
|
||||
bool File::unref() const
|
||||
{
|
||||
if (deref_base())
|
||||
return false;
|
||||
const_cast<File&>(*this).will_be_destroyed();
|
||||
delete this;
|
||||
return true;
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<OpenFileDescription>> File::open(int options)
|
||||
{
|
||||
auto description = OpenFileDescription::try_create(*this);
|
||||
|
@ -71,10 +71,9 @@ public:
|
||||
// - Should create a Region in the Process and return it if successful.
|
||||
|
||||
class File
|
||||
: public RefCountedBase
|
||||
: public RefCounted<File>
|
||||
, public Weakable<File> {
|
||||
public:
|
||||
virtual bool unref() const;
|
||||
virtual void will_be_destroyed() { }
|
||||
virtual ~File();
|
||||
|
||||
|
@ -15,7 +15,7 @@ class MasterPTY;
|
||||
|
||||
class SlavePTY final : public TTY {
|
||||
public:
|
||||
virtual bool unref() const override;
|
||||
bool unref() const;
|
||||
virtual ~SlavePTY() override;
|
||||
|
||||
void on_master_write(const UserOrKernelBuffer&, size_t);
|
||||
|
Loading…
Reference in New Issue
Block a user