]> OCCT Git - occt.git/commitdiff
0029960: Foundation Classes - disarm OSD_ThreadPool copy constructor
authorkgv <kgv@opencascade.com>
Sat, 14 Jul 2018 16:17:26 +0000 (19:17 +0300)
committerbugmaster <bugmaster@opencascade.com>
Fri, 20 Jul 2018 13:55:59 +0000 (16:55 +0300)
Private copy constructors have been added to OSD_ThreadPool
and Standard_Condition to protect misuse.

src/OSD/OSD_ThreadPool.hxx
src/Standard/Standard_Condition.hxx

index 8b6dab6ea3008fa8b3006fad91bec45a79f497e9..4b73100a8ca98adab1fe174c28cf96598555debe 100644 (file)
@@ -112,6 +112,7 @@ protected:
   {
     friend class OSD_ThreadPool;
   public:
+    //! Main constructor.
     EnumeratedThread (bool theIsSelfThread = false)
     : myPool (NULL), myJob (NULL), myWakeEvent (false),
       myIdleEvent (false), myThreadIndex (0), myUsageCounter(0),
@@ -131,6 +132,34 @@ protected:
     //! Wait the thread going into Idle state (finished jobs).
     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:
 
     //! Method is executed in the context of thread.
@@ -290,6 +319,12 @@ protected:
                           OSD_ThreadPool::JobInterface* theJob,
                           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:
 
   NCollection_Array1<EnumeratedThread> myThreads; //!< array of defined threads (excluding self-thread)
index c2f33dcdcd5d284416a0580328bae7e2978b3de4..d5c81913b32d4345c487f8d01e9a43ba1660cc97 100644 (file)
@@ -65,6 +65,12 @@ public:
   void* getHandle() const { return myEvent; }
 #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:
 
 #ifdef _WIN32