Another macOS std::list boost::thread SNAFU.
authorCarl Hetherington <cth@carlh.net>
Wed, 19 Feb 2020 21:22:23 +0000 (22:22 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 19 Feb 2020 21:22:23 +0000 (22:22 +0100)
src/lib/encode_server.cc
src/lib/encode_server.h

index e79f82b629e197d783f51a8201c05fc3316d6838..5884df09aae9642ccea356b640a9d4491ef4fa3e 100644 (file)
@@ -87,12 +87,13 @@ EncodeServer::~EncodeServer ()
                _full_condition.notify_all ();
        }
 
                _full_condition.notify_all ();
        }
 
-       BOOST_FOREACH (boost::thread& i, _worker_threads) {
+       BOOST_FOREACH (boost::thread* i, _worker_threads) {
                try {
                try {
-                       i.join ();
+                       i->join ();
                } catch (...) {
 
                }
                } catch (...) {
 
                }
+               delete i;
        }
 
        {
        }
 
        {
@@ -233,9 +234,10 @@ EncodeServer::run ()
        }
 
        for (int i = 0; i < _num_threads; ++i) {
        }
 
        for (int i = 0; i < _num_threads; ++i) {
-               _worker_threads.push_back (thread(bind(&EncodeServer::worker_thread, this)));
+               boost::thread* t = new thread(bind(&EncodeServer::worker_thread, this));
+               _worker_threads.push_back (t);
 #ifdef DCPOMATIC_LINUX
 #ifdef DCPOMATIC_LINUX
-               pthread_setname_np (_worker_threads.back().native_handle(), "encode-server-worker");
+               pthread_setname_np (t->native_handle(), "encode-server-worker");
 #endif
        }
 
 #endif
        }
 
index 40e84ad6029d9d7ff28d6f942923e989ffe7f549..91e0075039823f2616e719061ff517d899ed1760 100644 (file)
@@ -54,7 +54,7 @@ private:
        void broadcast_thread ();
        void broadcast_received ();
 
        void broadcast_thread ();
        void broadcast_received ();
 
-       std::vector<boost::thread> _worker_threads;
+       std::vector<boost::thread*> _worker_threads;
        std::list<boost::shared_ptr<Socket> > _queue;
        boost::condition _full_condition;
        boost::condition _empty_condition;
        std::list<boost::shared_ptr<Socket> > _queue;
        boost::condition _full_condition;
        boost::condition _empty_condition;