Aller au contenu
Bienvenue sur la nouvelle documentation de CppUtils !

Monitor Object wrapper encapsulating a resource with a mutex.

Ensures that all access to the underlying resource must pass through an Accessor RAII object that holds the mutex lock, guaranteeing at compile time that access to the protected data is synchronized.

Paramètre templateDescription
TThe type of the protected resource.
explicit UniqueLocker::UniqueLocker(auto&&... args);

Constructs the protected resource in place.

ParamètreDescription
argsArguments forwarded to the resource constructor.

UniqueLocker::UniqueLocker(const UniqueLocker&) = delete;

auto UniqueLocker::operator=(const UniqueLocker&) -> UniqueLocker& = delete;

UniqueLocker::UniqueLocker(UniqueLocker&& other) noexcept(std::is_nothrow_move_constructible_v<T>);

Move constructor. Acquires lock on the source locker before moving its value.


auto UniqueLocker::operator=(UniqueLocker&& other) noexcept(std::is_nothrow_move_assignable_v<T>) -> UniqueLocker&;

Move assignment. Acquires scoped lock on both mutexes before moving the value.


[[nodiscard]] auto UniqueLocker::access() & -> Accessor<T, std::mutex>;

Acquires exclusive read/write access to the resource.

Retourne : Accessor object managing the lock and providing access.


auto UniqueLocker::access() const& -> Accessor<const T, std::mutex>;

Acquires exclusive read-only access to the resource from an lvalue reference.

Retourne : Const Accessor object managing the lock.


auto UniqueLocker::access() const&& -> Accessor<const T, std::mutex>;

Acquires exclusive read-only access to the resource from an rvalue reference.

Retourne : Const Accessor object managing the lock.