267#include <system_error>
272template <
typename _Mutex_t>
303 template <
typename Rep,
typename Period>
306 const std::chrono::duration<Rep, Period>& _timeout_duration)
317 template <
typename Clock,
typename Duration>
320 const std::chrono::time_point<Clock, Duration>& _timeout_time)
332#ifdef G4MULTITHREADED
375#if defined(G4MULTITHREADED)
402#if defined(G4MULTITHREADED)
414 template <
typename Rep,
typename Period>
420 template <
typename Clock,
typename Duration>
439#define _is_stand_mutex(_Tp) (std::is_same<_Tp, G4Mutex>::value)
440#define _is_recur_mutex(_Tp) (std::is_same<_Tp, G4RecursiveMutex>::value)
441#define _is_other_mutex(_Tp) (!_is_stand_mutex(_Tp) && !_is_recur_mutex(_Tp))
443 template <
typename _Tp = _Mutex_t,
447 return "G4AutoLock<G4Mutex>";
450 template <
typename _Tp = _Mutex_t,
454 return "G4AutoLock<G4RecursiveMutex>";
457 template <
typename _Tp = _Mutex_t,
461 return "G4AutoLock<UNKNOWN_MUTEX>";
465#undef _is_stand_mutex
466#undef _is_recur_mutex
467#undef _is_other_mutex
470 template <
typename _Tp>
496#if defined(G4MULTITHREADED)
499 this->unique_lock_t::lock();
500 }
catch(std::system_error& e)
512 template <
typename Rep,
typename Period>
514 const std::chrono::duration<Rep, Period>& _timeout_duration)
516#if defined(G4MULTITHREADED)
519 this->unique_lock_t::try_lock_for(_timeout_duration);
520 }
catch(std::system_error& e)
534 template <
typename Clock,
typename Duration>
536 const std::chrono::time_point<Clock, Duration>& _timeout_time)
538#if defined(G4MULTITHREADED)
541 this->unique_lock_t::try_lock_until(_timeout_time);
542 }
catch(std::system_error& e)
560#if defined(G4VERBOSE)
561 cout <<
"Non-critical error: mutex lock failure in "
562 << GetTypeString<mutex_type>() <<
". "
563 <<
"If the app is terminating, Geant4 failed to "
564 <<
"delete an allocated resource and a Geant4 destructor is "
565 <<
"being called after the statics were destroyed. \n\t--> "
566 <<
"Exception: [code: " << e.code() <<
"] caught: " << e.what()
587template <
typename _Tp>
#define _is_recur_mutex(_Tp)
#define _is_stand_mutex(_Tp)
#define _is_other_mutex(_Tp)
G4TemplateAutoLock(mutex_type *_mutex, std::adopt_lock_t)
std::unique_lock< _Mutex_t > unique_lock_t
void _lock_deferred(const std::chrono::time_point< Clock, Duration > &_timeout_time)
G4TemplateAutoLock(mutex_type &_mutex, std::adopt_lock_t)
G4TemplateAutoLock(mutex_type *_mutex, std::defer_lock_t _lock) noexcept
bool try_lock_until(const std::chrono::time_point< Clock, Duration > &)
void swap(this_type &other) noexcept
std::string GetTypeString()
unique_lock_t::mutex_type mutex_type
G4TemplateAutoLock(mutex_type &_mutex, std::try_to_lock_t)
G4TemplateAutoLock(mutex_type *_mutex, std::try_to_lock_t)
G4TemplateAutoLock(mutex_type &_mutex, const std::chrono::duration< Rep, Period > &_timeout_duration)
G4TemplateAutoLock(mutex_type &_mutex)
void PrintLockErrorMessage(std::system_error &e)
bool try_lock_for(const std::chrono::duration< Rep, Period > &)
bool owns_lock() const noexcept
G4TemplateAutoLock< _Mutex_t > this_type
void _lock_deferred(const std::chrono::duration< Rep, Period > &_timeout_duration)
G4TemplateAutoLock(mutex_type &_mutex, const std::chrono::time_point< Clock, Duration > &_timeout_time)
G4TemplateAutoLock(mutex_type *_mutex)
void suppress_unused_variable(const _Tp &)
G4TemplateAutoLock(mutex_type &_mutex, std::defer_lock_t _lock) noexcept