Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/ApplicationFramework/TKCDF/CDF/CDF_Application.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <Standard_NoSuchObject.hxx>
#include <Standard_ProgramError.hxx>
#include <UTL.hxx>
#include <mutex>

IMPLEMENT_STANDARD_RTTIEXT(CDF_Application, CDM_Application)

Expand Down Expand Up @@ -327,6 +328,8 @@ occ::handle<CDM_Document> CDF_Application::Retrieve(const occ::handle<CDM_MetaDa
try
{
OCC_CATCH_SIGNALS
// theReader is shared across threads/calls for this format; Read() is not reentrant.
std::lock_guard<std::mutex> aDriverLock(theReader->Mutex());
theReader->Read(aMetaData->FileName(), aDocument, this, theFilter, theRange);
}
catch (Standard_Failure const& anException)
Expand Down Expand Up @@ -451,6 +454,8 @@ void CDF_Application::Read(Standard_IStream& theIStream,
try
{
OCC_CATCH_SIGNALS
// aReader is shared across threads/calls for this format; Read() is not reentrant.
std::lock_guard<std::mutex> aDriverLock(aReader->Mutex());
aReader->Read(theIStream, dData, theDocument, this, theFilter, theRange);
}
catch (Standard_Failure const& anException)
Expand Down
5 changes: 5 additions & 0 deletions src/ApplicationFramework/TKCDF/CDF/CDF_StoreList.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <CDM_ReferenceIterator.hxx>
#include <PCDM_StorageDriver.hxx>
#include <TCollection_ExtendedString.hxx>
#include <mutex>

IMPLEMENT_STANDARD_RTTIEXT(CDF_StoreList, Standard_Transient)

Expand Down Expand Up @@ -126,6 +127,10 @@ PCDM_StoreStatus CDF_StoreList::Store(occ::handle<CDM_MetaData>& aMetaData,
}
else
{
// aDocumentStorageDriver is shared across threads/calls for this format;
// Write() is not reentrant.
std::lock_guard<std::mutex> aDriverLock(aDocumentStorageDriver->Mutex());

// Reset the store-status.
// It has sense in multi-threaded access to the storage driver - this way we reset the
// status for each call.
Expand Down
7 changes: 7 additions & 0 deletions src/ApplicationFramework/TKCDF/PCDM/PCDM_Reader.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <Standard_IStream.hxx>
#include <Storage_Data.hxx>
#include <Message_ProgressRange.hxx>
#include <mutex>

class CDM_Document;
class TCollection_ExtendedString;
Expand Down Expand Up @@ -53,10 +54,16 @@ public:

PCDM_ReaderStatus GetStatus() const;

//! Guards Read(), which is not reentrant on a shared driver instance.
std::mutex& Mutex() const { return myMutex; }

DEFINE_STANDARD_RTTIEXT(PCDM_Reader, Standard_Transient)

protected:
PCDM_ReaderStatus myReaderStatus;

private:
mutable std::mutex myMutex;
};

#include <PCDM_Reader.lxx>
Expand Down
5 changes: 5 additions & 0 deletions src/ApplicationFramework/TKCDF/PCDM/PCDM_StorageDriver.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <PCDM_Writer.hxx>
#include <PCDM_Document.hxx>
#include <NCollection_Sequence.hxx>
#include <mutex>
class PCDM_Document;
class CDM_Document;

Expand Down Expand Up @@ -84,12 +85,16 @@ public:

Standard_EXPORT void SetStoreStatus(const PCDM_StoreStatus theStoreStatus);

//! Guards Write(), which is not reentrant on a shared driver instance.
std::mutex& Mutex() const { return myMutex; }

DEFINE_STANDARD_RTTIEXT(PCDM_StorageDriver, PCDM_Writer)

private:
TCollection_ExtendedString myFormat;
bool myIsError;
PCDM_StoreStatus myStoreStatus;
mutable std::mutex myMutex;
};

#endif // _PCDM_StorageDriver_HeaderFile
Loading