1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 01:17:35 +00:00

Kernel: Rename ProtectedValue<T> => MutexProtected<T>

Let's make it obvious what we're protecting it with.
This commit is contained in:
Andreas Kling 2021-08-21 23:31:15 +02:00
parent 81d990b551
commit c2fc33becd
18 changed files with 57 additions and 56 deletions

View file

@ -36,15 +36,15 @@ private:
MutexLocker m_mutex_locker;
};
class ContendedResource {
class MutexContendedResource {
template<typename, LockMode>
friend class LockedResource;
AK_MAKE_NONCOPYABLE(ContendedResource);
AK_MAKE_NONMOVABLE(ContendedResource);
AK_MAKE_NONCOPYABLE(MutexContendedResource);
AK_MAKE_NONMOVABLE(MutexContendedResource);
public:
ContendedResource() = default;
MutexContendedResource() = default;
protected:
mutable Mutex m_mutex;

View file

@ -6,28 +6,29 @@
#pragma once
#include <Kernel/Locking/ContendedResource.h>
#include <Kernel/Locking/LockLocation.h>
#include <Kernel/Locking/MutexContendedResource.h>
namespace Kernel {
template<typename T>
class ProtectedValue : private T
, public ContendedResource {
AK_MAKE_NONCOPYABLE(ProtectedValue);
AK_MAKE_NONMOVABLE(ProtectedValue);
class MutexProtected
: private T
, public MutexContendedResource {
AK_MAKE_NONCOPYABLE(MutexProtected);
AK_MAKE_NONMOVABLE(MutexProtected);
protected:
using LockedShared = LockedResource<T const, LockMode::Shared>;
using LockedExclusive = LockedResource<T, LockMode::Exclusive>;
LockedShared lock_shared(LockLocation const& location) const { return LockedShared(this, this->ContendedResource::m_mutex, location); }
LockedExclusive lock_exclusive(LockLocation const& location) { return LockedExclusive(this, this->ContendedResource::m_mutex, location); }
LockedShared lock_shared(LockLocation const& location) const { return LockedShared(this, this->MutexContendedResource::m_mutex, location); }
LockedExclusive lock_exclusive(LockLocation const& location) { return LockedExclusive(this, this->MutexContendedResource::m_mutex, location); }
public:
using T::T;
ProtectedValue() = default;
MutexProtected() = default;
template<typename Callback>
decltype(auto) with_shared(Callback callback, LockLocation const& location = LockLocation::current()) const