fix8  version 1.4.0
Open Source C++ FIX Framework
FIX8::f8_scoped_lock_impl< T > Class Template Reference

#include <thread.hpp>

Public Member Functions

 f8_scoped_lock_impl ()=default
 
 f8_scoped_lock_impl (T &mutex)
 
 f8_scoped_lock_impl (T &mutex, bool disable)
 
 ~f8_scoped_lock_impl ()
 
 f8_scoped_lock_impl (const f8_scoped_lock_impl &)=delete
 
f8_scoped_lock_imploperator= (const f8_scoped_lock_impl &)=delete
 
void acquire (T &mutex)
 
bool try_acquire (T &mutex)
 
void release ()
 

Private Attributes

T * _local_mutex = nullptr
 
bool _disabled = false
 

Detailed Description

template<typename T>
class FIX8::f8_scoped_lock_impl< T >

Definition at line 408 of file thread.hpp.

Constructor & Destructor Documentation

template<typename T >
FIX8::f8_scoped_lock_impl< T >::f8_scoped_lock_impl ( )
default
template<typename T >
FIX8::f8_scoped_lock_impl< T >::f8_scoped_lock_impl ( T &  mutex)
inline

Definition at line 415 of file thread.hpp.

415 { acquire(mutex); }
void acquire(T &mutex)
Definition: thread.hpp:427
template<typename T >
FIX8::f8_scoped_lock_impl< T >::f8_scoped_lock_impl ( T &  mutex,
bool  disable 
)
inline

Definition at line 416 of file thread.hpp.

416  : _disabled(disable)
417  {
418  if (!_disabled)
419  acquire(mutex);
420  }
void acquire(T &mutex)
Definition: thread.hpp:427
template<typename T >
FIX8::f8_scoped_lock_impl< T >::~f8_scoped_lock_impl ( )
inline

Definition at line 422 of file thread.hpp.

422 { release(); }
template<typename T >
FIX8::f8_scoped_lock_impl< T >::f8_scoped_lock_impl ( const f8_scoped_lock_impl< T > &  )
delete

Member Function Documentation

template<typename T >
void FIX8::f8_scoped_lock_impl< T >::acquire ( T &  mutex)
inline

Definition at line 427 of file thread.hpp.

428  {
429  mutex.lock();
430  _local_mutex = &mutex;
431  }
template<typename T >
f8_scoped_lock_impl& FIX8::f8_scoped_lock_impl< T >::operator= ( const f8_scoped_lock_impl< T > &  )
delete
template<typename T >
void FIX8::f8_scoped_lock_impl< T >::release ( )
inline

Definition at line 441 of file thread.hpp.

Referenced by FIX8::Logger::process_logline().

442  {
443  if (!_disabled && _local_mutex)
444  {
445  _local_mutex->unlock();
446  _local_mutex = nullptr;
447  }
448  }
template<typename T >
bool FIX8::f8_scoped_lock_impl< T >::try_acquire ( T &  mutex)
inline

Definition at line 433 of file thread.hpp.

434  {
435  bool result(mutex.try_lock());
436  if (result)
437  _local_mutex = &mutex;
438  return result;
439  }

Member Data Documentation

template<typename T >
bool FIX8::f8_scoped_lock_impl< T >::_disabled = false
private

Definition at line 411 of file thread.hpp.

template<typename T >
T* FIX8::f8_scoped_lock_impl< T >::_local_mutex = nullptr
private

Definition at line 410 of file thread.hpp.


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