SObjectizer  5.7
Public Member Functions | Private Attributes | List of all members
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::impl::stop_guard_repository_t

Public Member Functions

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

Private Attributes

Lock_Type m_lock
 Actual lock. More...
 

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

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.

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.

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