Selaa lähdekoodia

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.
Idan Horowitz 3 vuotta sitten
vanhempi
commit
6e2a82df13
3 muutettua tiedostoa jossa 2 lisäystä ja 12 poistoa
  1. 0 9
      Kernel/FileSystem/File.cpp
  2. 1 2
      Kernel/FileSystem/File.h
  3. 1 1
      Kernel/TTY/SlavePTY.h

+ 0 - 9
Kernel/FileSystem/File.cpp

@@ -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)
 ErrorOr<NonnullRefPtr<OpenFileDescription>> File::open(int options)
 {
 {
     auto description = OpenFileDescription::try_create(*this);
     auto description = OpenFileDescription::try_create(*this);

+ 1 - 2
Kernel/FileSystem/File.h

@@ -71,10 +71,9 @@ public:
 //   - Should create a Region in the Process and return it if successful.
 //   - Should create a Region in the Process and return it if successful.
 
 
 class File
 class File
-    : public RefCountedBase
+    : public RefCounted<File>
     , public Weakable<File> {
     , public Weakable<File> {
 public:
 public:
-    virtual bool unref() const;
     virtual void will_be_destroyed() { }
     virtual void will_be_destroyed() { }
     virtual ~File();
     virtual ~File();
 
 

+ 1 - 1
Kernel/TTY/SlavePTY.h

@@ -15,7 +15,7 @@ class MasterPTY;
 
 
 class SlavePTY final : public TTY {
 class SlavePTY final : public TTY {
 public:
 public:
-    virtual bool unref() const override;
+    bool unref() const;
     virtual ~SlavePTY() override;
     virtual ~SlavePTY() override;
 
 
     void on_master_write(const UserOrKernelBuffer&, size_t);
     void on_master_write(const UserOrKernelBuffer&, size_t);