changeset 2591:441f23af9d89 jobs

fix for older releases of boost::thread
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 16 May 2018 11:26:08 +0200
parents 5e2730c8e23c
children 23548462c77d
files Core/JobsEngine/JobsEngine.cpp Core/JobsEngine/JobsEngine.h
diffstat 2 files changed, 13 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/Core/JobsEngine/JobsEngine.cpp	Tue May 15 16:28:43 2018 +0200
+++ b/Core/JobsEngine/JobsEngine.cpp	Wed May 16 11:26:08 2018 +0200
@@ -226,7 +226,8 @@
 
     for (size_t i = 0; i < workers_.size(); i++)
     {
-      workers_[i] = boost::thread(Worker, this, i);
+      assert(workers_[i] == NULL);
+      workers_[i] = new boost::thread(Worker, this, i);
     }
 
     state_ = State_Running;
@@ -257,10 +258,14 @@
       
     for (size_t i = 0; i < workers_.size(); i++)
     {
-      if (workers_[i].joinable())
+      assert(workers_[i] != NULL);
+
+      if (workers_[i]->joinable())
       {
-        workers_[i].join();
+        workers_[i]->join();
       }
+
+      delete workers_[i];
     }
       
     {
--- a/Core/JobsEngine/JobsEngine.h	Tue May 15 16:28:43 2018 +0200
+++ b/Core/JobsEngine/JobsEngine.h	Wed May 16 11:26:08 2018 +0200
@@ -50,11 +50,11 @@
       State_Done
     };
 
-    boost::mutex                stateMutex_;
-    State                       state_;
-    JobsRegistry                registry_;
-    boost::thread               retryHandler_;
-    std::vector<boost::thread>  workers_;
+    boost::mutex                 stateMutex_;
+    State                        state_;
+    JobsRegistry                 registry_;
+    boost::thread                retryHandler_;
+    std::vector<boost::thread*>  workers_;
 
     bool IsRunning();