261 #ifndef G4AUTOLOCK_HH
262 #define G4AUTOLOCK_HH
268 #include <system_error>
274 template <
typename _Mutex_t>
305 template <
typename Rep,
typename Period>
307 const std::chrono::duration<Rep, Period>&
319 template<
typename Clock,
typename Duration>
321 const std::chrono::time_point<Clock, Duration>&
334 #ifdef G4MULTITHREADED
360 #endif // defined(G4MULTITHREADED)
377 #if defined(G4MULTITHREADED)
387 #else // NOT defined(G4MULTITHREADED) -- i.e. serial
397 #endif // defined(G4MULTITHREADED)
404 #if defined(G4MULTITHREADED)
408 #else // NOT defined(G4MULTITHREADED) -- i.e. serial
416 template <
typename Rep,
typename Period>
420 template <
typename Clock,
typename Duration>
433 #endif // defined(G4MULTITHREADED)
437 #define _is_stand_mutex(_Tp) (std::is_same<_Tp, G4Mutex>::value)
438 #define _is_recur_mutex(_Tp) (std::is_same<_Tp, G4RecursiveMutex>::value)
439 #define _is_other_mutex(_Tp) (! _is_stand_mutex(_Tp) && ! _is_recur_mutex(_Tp) )
441 template <
typename _Tp = _Mutex_t,
442 typename std::enable_if<_is_stand_mutex(_Tp), int>::type = 0>
445 template <
typename _Tp = _Mutex_t,
446 typename std::enable_if<_is_recur_mutex(_Tp), int>::type = 0>
449 template <
typename _Tp = _Mutex_t,
450 typename std::enable_if<_is_other_mutex(_Tp), int>::type = 0>
454 #undef _is_stand_mutex
455 #undef _is_recur_mutex
456 #undef _is_other_mutex
459 template <
typename _Tp>
484 #if defined(G4MULTITHREADED)
485 try { this->unique_lock_t::lock(); }
495 template <
typename Rep,
typename Period>
499 #if defined(G4MULTITHREADED)
500 try { this->unique_lock_t::try_lock_for(_timeout_duration); }
512 template<
typename Clock,
typename Duration>
516 #if defined(G4MULTITHREADED)
517 try { this->unique_lock_t::try_lock_until(_timeout_time); }
533 #if defined(G4VERBOSE)
534 cout <<
"Non-critical error: mutex lock failure in "
535 << GetTypeString<mutex_type>() <<
". "
536 <<
"If the app is terminating, Geant4 failed to "
537 <<
"delete an allocated resource and a Geant4 destructor is "
538 <<
"being called after the statics were destroyed. \n\t--> "
539 <<
"Exception: [code: " << e.code() <<
"] caught: "
563 #endif //G4AUTOLOCK_HH