Lely core libraries 1.9.2
mutex.hpp
Go to the documentation of this file.
1
22#ifndef LELY_COAPP_DETAIL_MUTEX_H_
23#define LELY_COAPP_DETAIL_MUTEX_H_
24
25#include <lely/coapp/coapp.hpp>
26
27#include <mutex>
28
29namespace lely {
30
31namespace canopen {
32
33namespace detail {
34
42template <class Mutex>
44 public:
49 typedef Mutex MutexType;
50
55 explicit UnlockGuard(MutexType& m) : m_(m) { m_.unlock(); }
56
61 UnlockGuard(MutexType& m, ::std::adopt_lock_t) : m_(m) {}
62
63 UnlockGuard(const UnlockGuard&) = delete;
64
65 UnlockGuard& operator=(const UnlockGuard&) = delete;
66
71 ~UnlockGuard() { m_.lock(); }
72
73 private:
74 MutexType& m_;
75};
76
77} // namespace detail
78
79} // namespace canopen
80
81} // namespace lely
82
83#endif // LELY_COAPP_DETAIL_MUTEX_H_
A mutex wrapper that provides a convenient RAII-style mechanism for releasing a mutex for the duratio...
Definition: mutex.hpp:43
~UnlockGuard()
Acquires ownership of m and calls m.lock(), where m is the mutex passed to the constructor.
Definition: mutex.hpp:71
UnlockGuard(MutexType &m, ::std::adopt_lock_t)
Releases ownership of m without attempting to unlock it.
Definition: mutex.hpp:61
UnlockGuard(MutexType &m)
Releases ownership of m and calls m.unlock().
Definition: mutex.hpp:55
Mutex MutexType
The type of the mutex to unlock.
Definition: mutex.hpp:49
This is the public header file of the C++ CANopen application library.
Global namespace for the Lely Industries N.V. libraries.
Definition: buf.hpp:32