SObjectizer 5.8
Loading...
Searching...
No Matches
so_5::details::actual_lock_holder_t< Lock_Type > Class Template Reference

A class to be used as mixin with actual std::mutex instance inside. More...

#include <sync_helpers.hpp>

Inheritance diagram for so_5::details::actual_lock_holder_t< Lock_Type >:
so_5::env_infrastructures::st_reusable_stuff::stats_controller_t< so_5::details::actual_lock_holder_t<> > so_5::impl::stop_guard_repository_t so_5::multi_sink_binding_t< Lock_Type > so_5::unique_subscribers_mbox_impl::actual_mbox_t< Mutex, Tracing_Base >

Public Member Functions

template<typename Lambda >
auto lock_and_perform (Lambda &&l) const -> decltype(l())
 Do actual lock and perform necessary action.
 

Private Attributes

Lock_Type m_lock
 Actual lock.
 

Detailed Description

template<typename Lock_Type = std::mutex>
class so_5::details::actual_lock_holder_t< Lock_Type >

A class to be used as mixin with actual std::mutex instance inside.

Usage example:

template< typename Lock_Holder >
class coop_repo_t final : protected Lock_Holder
{
public :
bool has_live_coop()
{
this->lock_and_perform([&]{ return !m_coops.empty(); });
}
};
using mtsafe_coop_repo_t = coop_repo_t< so_5::details::actual_lock_holder_t >;
Template Parameters
Lock_Typetype of lock to be used for object protection. Will be used with std::lock_guard.
Since
v.5.5.19

Definition at line 80 of file sync_helpers.hpp.

Member Function Documentation

◆ lock_and_perform()

template<typename Lock_Type = std::mutex>
template<typename Lambda >
auto so_5::details::actual_lock_holder_t< Lock_Type >::lock_and_perform ( Lambda && l) const -> decltype(l())
inline

Do actual lock and perform necessary action.

Definition at line 94 of file sync_helpers.hpp.

Member Data Documentation

◆ m_lock

template<typename Lock_Type = std::mutex>
Lock_Type so_5::details::actual_lock_holder_t< Lock_Type >::m_lock
mutableprivate

Actual lock.

Note
This is mutable attibute because locking can be necessary even in const methods of derived classes.

Definition at line 88 of file sync_helpers.hpp.


The documentation for this class was generated from the following file: