262 #ifndef G4AUTOLOCK_HH
263 #define G4AUTOLOCK_HH
269 #include <system_error>
275 template <
typename _Mutex_t>
306 template <
typename Rep,
typename Period>
308 const std::chrono::duration<Rep, Period>&
320 template<
typename Clock,
typename Duration>
322 const std::chrono::time_point<Clock, Duration>&
335 #ifdef G4MULTITHREADED
361 #endif // defined(G4MULTITHREADED)
378 #if defined(G4MULTITHREADED)
388 #else // NOT defined(G4MULTITHREADED) -- i.e. serial
398 #endif // defined(G4MULTITHREADED)
405 #if defined(G4MULTITHREADED)
409 #else // NOT defined(G4MULTITHREADED) -- i.e. serial
417 template <
typename Rep,
typename Period>
421 template <
typename Clock,
typename Duration>
434 #endif // defined(G4MULTITHREADED)
438 #define _is_stand_mutex(_Tp) (std::is_same<_Tp, G4Mutex>::value)
439 #define _is_recur_mutex(_Tp) (std::is_same<_Tp, G4RecursiveMutex>::value)
440 #define _is_other_mutex(_Tp) (! _is_stand_mutex(_Tp) && ! _is_recur_mutex(_Tp) )
442 template <
typename _Tp = _Mutex_t,
443 typename std::enable_if<_is_stand_mutex(_Tp), int>::type = 0>
446 template <
typename _Tp = _Mutex_t,
447 typename std::enable_if<_is_recur_mutex(_Tp), int>::type = 0>
450 template <
typename _Tp = _Mutex_t,
451 typename std::enable_if<_is_other_mutex(_Tp), int>::type = 0>
455 #undef _is_stand_mutex
456 #undef _is_recur_mutex
457 #undef _is_other_mutex
460 template <
typename _Tp>
485 #if defined(G4MULTITHREADED)
486 try { this->unique_lock_t::lock(); }
496 template <
typename Rep,
typename Period>
500 #if defined(G4MULTITHREADED)
501 try { this->unique_lock_t::try_lock_for(_timeout_duration); }
513 template<
typename Clock,
typename Duration>
517 #if defined(G4MULTITHREADED)
518 try { this->unique_lock_t::try_lock_until(_timeout_time); }
534 #if defined(G4VERBOSE)
535 cout <<
"Non-critical error: mutex lock failure in "
536 << GetTypeString<mutex_type>() <<
". "
537 <<
"If the app is terminating, Geant4 failed to "
538 <<
"delete an allocated resource and a Geant4 destructor is "
539 <<
"being called after the statics were destroyed. \n\t--> "
540 <<
"Exception: [code: " << e.code() <<
"] caught: "
564 #endif //G4AUTOLOCK_HH
void PrintLockErrorMessage(std::system_error &e)
G4TemplateAutoLock(mutex_type &_mutex, std::try_to_lock_t)
G4TemplateAutoLock< G4Mutex > G4AutoLock
void suppress_unused_variable(const _Tp &)
G4TemplateAutoLock< _Mutex_t > this_type
void swap(this_type &other) noexcept
G4TemplateAutoLock(mutex_type *_mutex, std::adopt_lock_t)
void _lock_deferred(const std::chrono::time_point< Clock, Duration > &_timeout_time)
G4TemplateAutoLock(mutex_type *_mutex, std::try_to_lock_t)
G4TemplateAutoLock(mutex_type *_mutex)
bool owns_lock() const noexcept
G4TemplateAutoLock(mutex_type &_mutex, const std::chrono::duration< Rep, Period > &_timeout_duration)
G4TemplateAutoLock(mutex_type *_mutex, std::defer_lock_t _lock) noexcept
bool try_lock_until(const std::chrono::time_point< Clock, Duration > &)
unique_lock_t::mutex_type mutex_type
G4TemplateAutoLock(mutex_type &_mutex, std::adopt_lock_t)
G4TemplateAutoLock(mutex_type &_mutex, std::defer_lock_t _lock) noexcept
const G4ThreeVector const G4double const
std::string GetTypeString()
G4TemplateAutoLock(mutex_type &_mutex)
void _lock_deferred(const std::chrono::duration< Rep, Period > &_timeout_duration)
G4TemplateAutoLock< G4RecursiveMutex > G4RecursiveAutoLock
bool try_lock_for(const std::chrono::duration< Rep, Period > &)
G4TemplateAutoLock(mutex_type &_mutex, const std::chrono::time_point< Clock, Duration > &_timeout_time)
std::unique_lock< _Mutex_t > unique_lock_t