μHAL (v2.8.17)
Part of the IPbus software repository
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
RobustSessionMutex.hpp
Go to the documentation of this file.
1
2#ifndef _uhal_detail_RobustSessionMutex_hpp_
3#define _uhal_detail_RobustSessionMutex_hpp_
4
5#include <cstdint>
6#include <mutex>
7#include <pthread.h>
8
11
12
13namespace uhal {
14namespace detail {
15
17UHAL_DEFINE_DERIVED_EXCEPTION_CLASS ( MutexError , uhal::exception::TransportLayerError , "Exception class to handle errors from pthread mutex-related functions." )
18
19
28public:
31
32 void lock();
33
34 void unlock();
35
36 uint64_t getCounter() const;
37
38 bool isActive() const;
39
40 void startSession();
41
42 void endSession();
43
44private:
46
47 pthread_mutex_t mMutex;
48 uint64_t mCount;
50};
51
52
53typedef std::unique_lock<RobustSessionMutex> ScopedSessionLock;
54
55}
56}
57
58#endif
Exception class to handle errors from pthread mutex-related functions.
RobustSessionMutex(const RobustSessionMutex &)
#define UHAL_DEFINE_DERIVED_EXCEPTION_CLASS(ClassName, BaseClassName, ClassDescription)
Macro for simplifying the declaration and definition of derived exception types.
Definition: exception.hpp:49
std::unique_lock< RobustSessionMutex > ScopedSessionLock