mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-29 14:00:49 +03:00
Temporary fix for 0029872: Express Mesh - instrument the algorithm with progress indicator
Make ProgressSentry thread safe. It will update indicator only when it is executed in the thread where it was created.
This commit is contained in:
@@ -27,7 +27,8 @@ Message_ProgressSentry::Message_ProgressSentry (const Handle(Message_ProgressInd
|
||||
const Standard_Real step,
|
||||
const Standard_Boolean isInf,
|
||||
const Standard_Real newScopeSpan) :
|
||||
myProgress(progress), myActive(!progress.IsNull())
|
||||
myProgress(progress), myActive(!progress.IsNull()),
|
||||
myThreadId(OSD_Thread::Current())
|
||||
{
|
||||
if ( ! myActive ) return;
|
||||
progress->SetName ( name );
|
||||
@@ -47,7 +48,8 @@ Message_ProgressSentry::Message_ProgressSentry (const Handle(Message_ProgressInd
|
||||
const Standard_Real step,
|
||||
const Standard_Boolean isInf,
|
||||
const Standard_Real newScopeSpan) :
|
||||
myProgress(progress), myActive(!progress.IsNull())
|
||||
myProgress(progress), myActive(!progress.IsNull()),
|
||||
myThreadId(OSD_Thread::Current())
|
||||
{
|
||||
if ( ! myActive ) return;
|
||||
progress->SetName ( name );
|
||||
|
@@ -23,6 +23,8 @@
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <Standard_CString.hxx>
|
||||
#include <Standard_Real.hxx>
|
||||
#include <Standard_ThreadId.hxx>
|
||||
#include <OSD_Thread.hxx>
|
||||
class Message_ProgressIndicator;
|
||||
class TCollection_HAsciiString;
|
||||
|
||||
@@ -109,6 +111,7 @@ private:
|
||||
|
||||
Handle(Message_ProgressIndicator) myProgress;
|
||||
Standard_Boolean myActive;
|
||||
Standard_ThreadId myThreadId;
|
||||
|
||||
|
||||
};
|
||||
|
@@ -20,7 +20,7 @@
|
||||
|
||||
inline void Message_ProgressSentry::Relieve ()
|
||||
{
|
||||
if ( ! myActive ) return;
|
||||
if (!myActive || myThreadId != OSD_Thread::Current()) return;
|
||||
myProgress->EndScope();
|
||||
myActive = 0;
|
||||
}
|
||||
@@ -32,7 +32,8 @@ inline void Message_ProgressSentry::Relieve ()
|
||||
|
||||
inline void Message_ProgressSentry::Next (const Standard_CString name) const
|
||||
{
|
||||
if ( myActive ) myProgress->NextScope(name);
|
||||
if (myActive && myThreadId == OSD_Thread::Current())
|
||||
myProgress->NextScope(name);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -43,7 +44,8 @@ inline void Message_ProgressSentry::Next (const Standard_CString name) const
|
||||
inline void Message_ProgressSentry::Next (const Standard_Real span,
|
||||
const Standard_CString name) const
|
||||
{
|
||||
if ( myActive ) myProgress->NextScope(span, name);
|
||||
if (myActive && myThreadId == OSD_Thread::Current())
|
||||
myProgress->NextScope(span, name);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -54,7 +56,7 @@ inline void Message_ProgressSentry::Next (const Standard_Real span,
|
||||
inline void Message_ProgressSentry::Next (const Standard_Real span,
|
||||
const Handle(TCollection_HAsciiString)& name) const
|
||||
{
|
||||
if ( myActive ) {
|
||||
if (myActive && myThreadId == OSD_Thread::Current()) {
|
||||
myProgress->EndScope();
|
||||
myProgress->NewScope(span, name);
|
||||
}
|
||||
@@ -77,5 +79,6 @@ inline Standard_Boolean Message_ProgressSentry::More () const
|
||||
|
||||
inline void Message_ProgressSentry::Show () const
|
||||
{
|
||||
if ( ! myProgress.IsNull() ) myProgress->Show();
|
||||
if (!myProgress.IsNull() && myThreadId == OSD_Thread::Current())
|
||||
myProgress->Show();
|
||||
}
|
||||
|
Reference in New Issue
Block a user