1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-05 18:16:23 +03:00

0029960: Foundation Classes - disarm OSD_ThreadPool copy constructor

Private copy constructors have been added to OSD_ThreadPool
and Standard_Condition to protect misuse.
This commit is contained in:
kgv 2018-07-14 19:17:26 +03:00 committed by bugmaster
parent ffe1b14331
commit ca0962a1e9
2 changed files with 41 additions and 0 deletions

View File

@ -112,6 +112,7 @@ protected:
{ {
friend class OSD_ThreadPool; friend class OSD_ThreadPool;
public: public:
//! Main constructor.
EnumeratedThread (bool theIsSelfThread = false) EnumeratedThread (bool theIsSelfThread = false)
: myPool (NULL), myJob (NULL), myWakeEvent (false), : myPool (NULL), myJob (NULL), myWakeEvent (false),
myIdleEvent (false), myThreadIndex (0), myUsageCounter(0), myIdleEvent (false), myThreadIndex (0), myUsageCounter(0),
@ -131,6 +132,34 @@ protected:
//! Wait the thread going into Idle state (finished jobs). //! Wait the thread going into Idle state (finished jobs).
Standard_EXPORT void WaitIdle(); Standard_EXPORT void WaitIdle();
public:
//! Copy constructor.
EnumeratedThread (const EnumeratedThread& theCopy)
: OSD_Thread(),
myPool (NULL), myJob (NULL), myWakeEvent (false),
myIdleEvent (false), myThreadIndex (0), myUsageCounter(0),
myIsStarted (false), myToCatchFpe (false),
myIsSelfThread (false) { Assign (theCopy); }
//! Assignment operator.
EnumeratedThread& operator= (const EnumeratedThread& theCopy)
{
Assign (theCopy);
return *this;
}
//! Assignment operator.
void Assign (const EnumeratedThread& theCopy)
{
OSD_Thread::Assign (theCopy);
myPool = theCopy.myPool;
myJob = theCopy.myJob;
myThreadIndex = theCopy.myThreadIndex;
myToCatchFpe = theCopy.myToCatchFpe;
myIsSelfThread = theCopy.myIsSelfThread;
}
private: private:
//! Method is executed in the context of thread. //! Method is executed in the context of thread.
@ -290,6 +319,12 @@ protected:
OSD_ThreadPool::JobInterface* theJob, OSD_ThreadPool::JobInterface* theJob,
int theThreadIndex); int theThreadIndex);
private:
//! This method should not be called (prohibited).
OSD_ThreadPool (const OSD_ThreadPool& theCopy);
//! This method should not be called (prohibited).
OSD_ThreadPool& operator= (const OSD_ThreadPool& theCopy);
private: private:
NCollection_Array1<EnumeratedThread> myThreads; //!< array of defined threads (excluding self-thread) NCollection_Array1<EnumeratedThread> myThreads; //!< array of defined threads (excluding self-thread)

View File

@ -65,6 +65,12 @@ public:
void* getHandle() const { return myEvent; } void* getHandle() const { return myEvent; }
#endif #endif
private:
//! This method should not be called (prohibited).
Standard_Condition (const Standard_Condition& theCopy);
//! This method should not be called (prohibited).
Standard_Condition& operator= (const Standard_Condition& theCopy);
private: private:
#ifdef _WIN32 #ifdef _WIN32