1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:17:44 +00:00

Kernel: Use RefPtr instead of LockRefPtr for Custody

By protecting all the RefPtr<Custody> objects that may be accessed from
multiple threads at the same time (with spinlocks), we remove the need
for using LockRefPtr<Custody> (which is basically a RefPtr with a
built-in spinlock.)
This commit is contained in:
Andreas Kling 2022-08-21 01:04:35 +02:00
parent 5331d243c6
commit 728c3fbd14
23 changed files with 143 additions and 102 deletions

View file

@ -8,22 +8,22 @@
#include <AK/Error.h>
#include <AK/IntrusiveList.h>
#include <AK/RefPtr.h>
#include <Kernel/Forward.h>
#include <Kernel/KString.h>
#include <Kernel/Library/ListedRefCounted.h>
#include <Kernel/Library/LockRefPtr.h>
#include <Kernel/Locking/SpinlockProtected.h>
namespace Kernel {
class Custody : public ListedRefCounted<Custody, LockType::Spinlock> {
class Custody final : public ListedRefCounted<Custody, LockType::Spinlock> {
public:
static ErrorOr<NonnullLockRefPtr<Custody>> try_create(Custody* parent, StringView name, Inode&, int mount_flags);
static ErrorOr<NonnullRefPtr<Custody>> try_create(Custody* parent, StringView name, Inode&, int mount_flags);
~Custody();
Custody* parent() { return m_parent.ptr(); }
Custody const* parent() const { return m_parent.ptr(); }
RefPtr<Custody> parent() { return m_parent; }
RefPtr<Custody const> parent() const { return m_parent; }
Inode& inode() { return *m_inode; }
Inode const& inode() const { return *m_inode; }
StringView name() const { return m_name->view(); }
@ -35,7 +35,7 @@ public:
private:
Custody(Custody* parent, NonnullOwnPtr<KString> name, Inode&, int mount_flags);
LockRefPtr<Custody> m_parent;
RefPtr<Custody> m_parent;
NonnullOwnPtr<KString> m_name;
NonnullLockRefPtr<Inode> m_inode;
int m_mount_flags { 0 };