diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-11-06 16:43:01 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-11-06 16:43:01 +0000 |
| commit | 59602b67d0637817a156b7bd0fc05f96fe41dee5 (patch) | |
| tree | 3214f9f260796cf673c8bc69b069fd63b8a0889c /src/lib/encoder.cc | |
| parent | 4c7416beb0efbf74868f756ddf8013f93c5841dc (diff) | |
Various bits of server tidying up.
Diffstat (limited to 'src/lib/encoder.cc')
| -rw-r--r-- | src/lib/encoder.cc | 33 |
1 files changed, 8 insertions, 25 deletions
diff --git a/src/lib/encoder.cc b/src/lib/encoder.cc index 2ec32deb7..ccaeab18c 100644 --- a/src/lib/encoder.cc +++ b/src/lib/encoder.cc @@ -79,9 +79,7 @@ void Encoder::add_worker_threads (ServerDescription d) { for (int i = 0; i < d.threads(); ++i) { - _threads.push_back ( - make_pair (d, new boost::thread (boost::bind (&Encoder::encoder_thread, this, d))) - ); + _threads.push_back (new boost::thread (boost::bind (&Encoder::encoder_thread, this, d))); } } @@ -89,12 +87,7 @@ void Encoder::process_begin () { for (int i = 0; i < Config::instance()->num_local_encoding_threads (); ++i) { - _threads.push_back ( - make_pair ( - optional<ServerDescription> (), - new boost::thread (boost::bind (&Encoder::encoder_thread, this, optional<ServerDescription> ())) - ) - ); + _threads.push_back (new boost::thread (boost::bind (&Encoder::encoder_thread, this, optional<ServerDescription> ()))); } vector<ServerDescription> servers = Config::instance()->servers (); @@ -104,8 +97,7 @@ Encoder::process_begin () } _writer.reset (new Writer (_film, _job)); - _server_finder.reset (new ServerFinder ()); - _server_finder->ServerFound.connect (boost::bind (&Encoder::server_found, this, _1)); + ServerFinder::instance()->connect (boost::bind (&Encoder::server_found, this, _1)); } @@ -257,11 +249,11 @@ Encoder::terminate_threads () _condition.notify_all (); } - for (ThreadList::iterator i = _threads.begin(); i != _threads.end(); ++i) { - if (i->second->joinable ()) { - i->second->join (); + for (list<boost::thread *>::iterator i = _threads.begin(); i != _threads.end(); ++i) { + if ((*i)->joinable ()) { + (*i)->join (); } - delete i->second; + delete *i; } _threads.clear (); @@ -354,14 +346,5 @@ Encoder::encoder_thread (optional<ServerDescription> server) void Encoder::server_found (ServerDescription s) { - /* See if we already know about this server */ - boost::mutex::scoped_lock lm (_mutex); - ThreadList::iterator i = _threads.begin(); - while (i != _threads.end() && (!i->first || i->first.get().host_name() != s.host_name())) { - ++i; - } - - if (i == _threads.end ()) { - add_worker_threads (s); - } + add_worker_threads (s); } |
