251#include <system_error>
258template <
typename MutexT>
289 template <
typename Rep,
typename Period>
291 const std::chrono::duration<Rep, Period>& _timeout_duration)
302 template <
typename Clock,
typename Duration>
304 const std::chrono::time_point<Clock, Duration>& _timeout_time)
353#define _is_stand_mutex(Tp) (std::is_same<Tp, Mutex>::value)
354#define _is_recur_mutex(Tp) (std::is_same<Tp, RecursiveMutex>::value)
355#define _is_other_mutex(Tp) (!_is_stand_mutex(Tp) && !_is_recur_mutex(Tp))
357 template <
typename Tp = MutexT,
361 return "AutoLock<Mutex>";
364 template <
typename Tp = MutexT,
368 return "AutoLock<RecursiveMutex>";
371 template <
typename Tp = MutexT,
375 return "AutoLock<UNKNOWN_MUTEX>";
379#undef _is_stand_mutex
380#undef _is_recur_mutex
381#undef _is_other_mutex
384 template <
typename Tp>
412 this->unique_lock_t::lock();
413 }
catch(std::system_error& e)
424 template <
typename Rep,
typename Period>
429 this->unique_lock_t::try_lock_for(_timeout_duration);
430 }
catch(std::system_error& e)
441 template <
typename Clock,
typename Duration>
442 void _lock_deferred(
const std::chrono::time_point<Clock, Duration>& _timeout_time)
446 this->unique_lock_t::try_lock_until(_timeout_time);
447 }
catch(std::system_error& e)
463 cout <<
"Non-critical error: mutex lock failure in "
464 << GetTypeString<mutex_type>() <<
". "
465 <<
"If the app is terminating, Tasking failed to "
466 <<
"delete an allocated resource and a Tasking destructor is "
467 <<
"being called after the statics were destroyed. \n\t--> "
468 <<
"Exception: [code: " << e.code() <<
"] caught: " << e.what() << std::endl;
488template <
typename Tp>
#define _is_other_mutex(Tp)
#define _is_stand_mutex(Tp)
#define _is_recur_mutex(Tp)
TemplateAutoLock(mutex_type *_mutex, std::try_to_lock_t _lock)
TemplateAutoLock(mutex_type &_mutex, std::defer_lock_t _lock) noexcept
TemplateAutoLock(mutex_type *_mutex)
void suppress_unused_variable(const Tp &)
unique_lock_t::mutex_type mutex_type
TemplateAutoLock< MutexT > this_type
TemplateAutoLock(mutex_type &_mutex, std::try_to_lock_t _lock)
TemplateAutoLock(mutex_type &_mutex, const std::chrono::duration< Rep, Period > &_timeout_duration)
TemplateAutoLock(mutex_type *_mutex, std::defer_lock_t _lock) noexcept
std::string GetTypeString()
std::unique_lock< MutexT > unique_lock_t
TemplateAutoLock(mutex_type *_mutex, std::adopt_lock_t _lock)
TemplateAutoLock(mutex_type &_mutex, std::adopt_lock_t _lock)
TemplateAutoLock(mutex_type &_mutex)
void _lock_deferred(const std::chrono::duration< Rep, Period > &_timeout_duration)
TemplateAutoLock(mutex_type &_mutex, const std::chrono::time_point< Clock, Duration > &_timeout_time)
void PrintLockErrorMessage(std::system_error &e)
void _lock_deferred(const std::chrono::time_point< Clock, Duration > &_timeout_time)
TemplateAutoLock< RecursiveMutex > RecursiveAutoLock
TemplateAutoLock< Mutex > AutoLock