//! 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,
myRootScope->myValue = 0.;
Reset();
Show (*myRootScope, Standard_False);
+ myRootScope->myIsActive = IsActive();
return myRootScope->Next();
}
//! 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.
#include <Standard_Mutex.hxx>
-//=============================================
-// 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
//=============================================
#include <time.h>
#endif
+#include <mutex>
+
/**
* @brief Mutex: a class to synchronize access to shared data.
*
}
//! 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;
//! 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:
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_Mutex> 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 */