mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 19:58:11 +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:
parent
5331d243c6
commit
728c3fbd14
23 changed files with 143 additions and 102 deletions
|
@ -14,7 +14,7 @@ namespace Kernel {
|
|||
Mount::Mount(FileSystem& guest_fs, Custody* host_custody, int flags)
|
||||
: m_guest(guest_fs.root_inode())
|
||||
, m_guest_fs(guest_fs)
|
||||
, m_host_custody(host_custody)
|
||||
, m_host_custody(LockRank::None, host_custody)
|
||||
, m_flags(flags)
|
||||
{
|
||||
}
|
||||
|
@ -22,30 +22,36 @@ Mount::Mount(FileSystem& guest_fs, Custody* host_custody, int flags)
|
|||
Mount::Mount(Inode& source, Custody& host_custody, int flags)
|
||||
: m_guest(source)
|
||||
, m_guest_fs(source.fs())
|
||||
, m_host_custody(host_custody)
|
||||
, m_host_custody(LockRank::None, host_custody)
|
||||
, m_flags(flags)
|
||||
{
|
||||
}
|
||||
|
||||
ErrorOr<NonnullOwnPtr<KString>> Mount::absolute_path() const
|
||||
{
|
||||
if (!m_host_custody)
|
||||
return KString::try_create("/"sv);
|
||||
return m_host_custody->try_serialize_absolute_path();
|
||||
return m_host_custody.with([&](auto& host_custody) -> ErrorOr<NonnullOwnPtr<KString>> {
|
||||
if (!host_custody)
|
||||
return KString::try_create("/"sv);
|
||||
return host_custody->try_serialize_absolute_path();
|
||||
});
|
||||
}
|
||||
|
||||
Inode* Mount::host()
|
||||
LockRefPtr<Inode> Mount::host()
|
||||
{
|
||||
if (!m_host_custody)
|
||||
return nullptr;
|
||||
return &m_host_custody->inode();
|
||||
return m_host_custody.with([](auto& host_custody) -> LockRefPtr<Inode> {
|
||||
if (!host_custody)
|
||||
return nullptr;
|
||||
return &host_custody->inode();
|
||||
});
|
||||
}
|
||||
|
||||
Inode const* Mount::host() const
|
||||
LockRefPtr<Inode const> Mount::host() const
|
||||
{
|
||||
if (!m_host_custody)
|
||||
return nullptr;
|
||||
return &m_host_custody->inode();
|
||||
return m_host_custody.with([](auto& host_custody) -> LockRefPtr<Inode const> {
|
||||
if (!host_custody)
|
||||
return nullptr;
|
||||
return &host_custody->inode();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue