diff --git a/src/Draw/Draw_ProgressIndicator.hxx b/src/Draw/Draw_ProgressIndicator.hxx index 393701fd86..965c3801ac 100644 --- a/src/Draw/Draw_ProgressIndicator.hxx +++ b/src/Draw/Draw_ProgressIndicator.hxx @@ -65,6 +65,11 @@ public: //! Clears/erases opened TCL windows if any //! and sets myBreak to False Standard_EXPORT virtual void Reset() Standard_OVERRIDE; + + Standard_Boolean IsActive() const Standard_OVERRIDE + { + return myGraphMode || myTclMode || myConsoleMode; + } //! Defines method Show of Progress Indicator Standard_EXPORT virtual void Show (const Message_ProgressScope& theScope, diff --git a/src/Message/Message_ProgressIndicator.cxx b/src/Message/Message_ProgressIndicator.cxx index 6abf893f9c..a745fbf9fe 100644 --- a/src/Message/Message_ProgressIndicator.cxx +++ b/src/Message/Message_ProgressIndicator.cxx @@ -48,6 +48,7 @@ Message_ProgressRange Message_ProgressIndicator::Start() myRootScope->myValue = 0.; Reset(); Show (*myRootScope, Standard_False); + myRootScope->myIsActive = IsActive(); return myRootScope->Next(); } diff --git a/src/Message/Message_ProgressIndicator.hxx b/src/Message/Message_ProgressIndicator.hxx index ad6e5e547e..1efadc78ef 100644 --- a/src/Message/Message_ProgressIndicator.hxx +++ b/src/Message/Message_ProgressIndicator.hxx @@ -67,6 +67,8 @@ public: //! Use this method to get the top level range for progress indication. Standard_EXPORT Message_ProgressRange Start(); + virtual Standard_Boolean IsActive() const { return true; } + //! If argument is non-null handle, returns theProgress->Start(). //! Otherwise, returns dummy range that can be safely used in the algorithms //! but not bound to progress indicator. diff --git a/src/Standard/Standard_Mutex.cxx b/src/Standard/Standard_Mutex.cxx index 41090571de..7e067aa7db 100644 --- a/src/Standard/Standard_Mutex.cxx +++ b/src/Standard/Standard_Mutex.cxx @@ -15,62 +15,6 @@ #include -//============================================= -// Standard_Mutex::Standard_Mutex -//============================================= - -Standard_Mutex::Standard_Mutex () -{ -#if (defined(_WIN32) || defined(__WIN32__)) - InitializeCriticalSection (&myMutex); -#else - pthread_mutexattr_t anAttr; - pthread_mutexattr_init (&anAttr); - pthread_mutexattr_settype (&anAttr, PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init (&myMutex, &anAttr); - pthread_mutexattr_destroy (&anAttr); -#endif -} - -//============================================= -// Standard_Mutex::~Standard_Mutex -//============================================= - -Standard_Mutex::~Standard_Mutex () -{ -#if (defined(_WIN32) || defined(__WIN32__)) - DeleteCriticalSection (&myMutex); -#else - pthread_mutex_destroy (&myMutex); -#endif -} - -//============================================= -// Standard_Mutex::Lock -//============================================= - -void Standard_Mutex::Lock () -{ -#if (defined(_WIN32) || defined(__WIN32__)) - EnterCriticalSection (&myMutex); -#else - pthread_mutex_lock (&myMutex); -#endif -} - -//============================================= -// Standard_Mutex::TryLock -//============================================= - -Standard_Boolean Standard_Mutex::TryLock () -{ -#if (defined(_WIN32) || defined(__WIN32__)) - return (TryEnterCriticalSection (&myMutex) != 0); -#else - return (pthread_mutex_trylock (&myMutex) != EBUSY); -#endif -} - //============================================= // Standard_Mutex::DestroyCallback //============================================= diff --git a/src/Standard/Standard_Mutex.hxx b/src/Standard/Standard_Mutex.hxx index 7197979d4d..c3758dad62 100644 --- a/src/Standard/Standard_Mutex.hxx +++ b/src/Standard/Standard_Mutex.hxx @@ -29,6 +29,8 @@ #include #endif +#include + /** * @brief Mutex: a class to synchronize access to shared data. * @@ -122,9 +124,9 @@ public: } //! This method should not be called (prohibited). - Sentry (const Sentry &); + Sentry (const Sentry &) = delete; //! This method should not be called (prohibited). - Sentry& operator = (const Sentry &); + Sentry& operator = (const Sentry &) = delete; private: Standard_Mutex* myMutex; @@ -135,22 +137,22 @@ public: //! Constructor: creates a mutex object and initializes it. //! It is strongly recommended that mutexes were created as //! static objects whenever possible. - Standard_EXPORT Standard_Mutex (); + Standard_Mutex() {}; //! Destructor: destroys the mutex object - Standard_EXPORT ~Standard_Mutex (); + ~Standard_Mutex() {}; //! Method to lock the mutex; waits until the mutex is released //! by other threads, locks it and then returns - Standard_EXPORT void Lock (); + void Lock() { myMutex.lock(); } //! Method to test the mutex; if the mutex is not hold by other thread, //! locks it and returns True; otherwise returns False without waiting //! mutex to be released. - Standard_EXPORT Standard_Boolean TryLock (); + Standard_Boolean TryLock () { return myMutex.try_lock(); } //! Method to unlock the mutex; releases it to other users - void Unlock (); + void Unlock() { myMutex.unlock(); } private: @@ -158,29 +160,14 @@ private: Standard_EXPORT virtual void DestroyCallback() Standard_OVERRIDE; //! This method should not be called (prohibited). - Standard_Mutex (const Standard_Mutex &); + Standard_Mutex (const Standard_Mutex &) = delete; //! This method should not be called (prohibited). - Standard_Mutex& operator = (const Standard_Mutex &); + Standard_Mutex& operator = (const Standard_Mutex &) = delete; private: -#if (defined(_WIN32) || defined(__WIN32__)) - CRITICAL_SECTION myMutex; -#else - pthread_mutex_t myMutex; -#endif + std::recursive_mutex myMutex; }; typedef NCollection_Shared Standard_HMutex; -// Implementation of the method Unlock is inline, since it is -// just a shortcut to system function -inline void Standard_Mutex::Unlock () -{ -#if (defined(_WIN32) || defined(__WIN32__)) - LeaveCriticalSection (&myMutex); -#else - pthread_mutex_unlock (&myMutex); -#endif -} - #endif /* _Standard_Mutex_HeaderFile */