diff options
| author | Carl Hetherington <cth@carlh.net> | 2017-04-27 11:57:15 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2017-04-27 11:57:15 +0100 |
| commit | 1f7f758273eb3c98356438da897b7709f8cb87f0 (patch) | |
| tree | 06fb17aa8ee01c91779402f1abb3c5d2a389ed7a /src/lib | |
| parent | 350c6ca06fd782917586d039850c93f8f9613707 (diff) | |
Distinguish master DoM encode threads count from the server count.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/config.cc | 14 | ||||
| -rw-r--r-- | src/lib/config.h | 26 | ||||
| -rw-r--r-- | src/lib/encoder.cc | 2 | ||||
| -rw-r--r-- | src/lib/film.cc | 2 | ||||
| -rw-r--r-- | src/lib/writer.cc | 2 |
5 files changed, 32 insertions, 14 deletions
diff --git a/src/lib/config.cc b/src/lib/config.cc index de44c5c77..9fdf57207 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -72,7 +72,8 @@ Config::Config () void Config::set_defaults () { - _num_local_encoding_threads = max (2U, boost::thread::hardware_concurrency ()); + _master_encoding_threads = max (2U, boost::thread::hardware_concurrency ()); + _server_encoding_threads = max (2U, boost::thread::hardware_concurrency ()); _server_port_base = 6192; _use_any_servers = true; _servers.clear (); @@ -162,7 +163,13 @@ try optional<int> version = f.optional_number_child<int> ("Version"); - _num_local_encoding_threads = f.number_child<int> ("NumLocalEncodingThreads"); + if (f.optional_number_child<int>("NumLocalEncodingThreads")) { + _master_encoding_threads = _server_encoding_threads = f.optional_number_child<int>("NumLocalEncodingThreads").get(); + } else { + _master_encoding_threads = f.number_child<int>("MasterEncodingThreads"); + _server_encoding_threads = f.number_child<int>("ServerEncodingThreads"); + } + _default_directory = f.optional_string_child ("DefaultDirectory"); if (_default_directory && _default_directory->empty ()) { /* We used to store an empty value for this to mean "none set" */ @@ -392,7 +399,8 @@ Config::write_config () const xmlpp::Element* root = doc.create_root_node ("Config"); root->add_child("Version")->add_child_text ("2"); - root->add_child("NumLocalEncodingThreads")->add_child_text (raw_convert<string> (_num_local_encoding_threads)); + root->add_child("MasterEncodingThreads")->add_child_text (raw_convert<string> (_master_encoding_threads)); + root->add_child("ServerEncodingThreads")->add_child_text (raw_convert<string> (_server_encoding_threads)); if (_default_directory) { root->add_child("DefaultDirectory")->add_child_text (_default_directory->string ()); } diff --git a/src/lib/config.h b/src/lib/config.h index a574cc261..40380f825 100644 --- a/src/lib/config.h +++ b/src/lib/config.h @@ -47,9 +47,14 @@ class Film; class Config : public boost::noncopyable { public: - /** @return number of threads to use for J2K encoding on the local machine */ - int num_local_encoding_threads () const { - return _num_local_encoding_threads; + /** @return number of threads which a master DoM should use for J2K encoding on the local machine */ + int master_encoding_threads () const { + return _master_encoding_threads; + } + + /** @return number of threads which a server should use for J2K encoding on the local machine */ + int server_encoding_threads () const { + return _server_encoding_threads; } boost::optional<boost::filesystem::path> default_directory () const { @@ -316,9 +321,12 @@ public: return _preview_sound_output; } - /** @param n New number of local encoding threads */ - void set_num_local_encoding_threads (int n) { - maybe_set (_num_local_encoding_threads, n); + void set_master_encoding_threads (int n) { + maybe_set (_master_encoding_threads, n); + } + + void set_server_encoding_threads (int n) { + maybe_set (_server_encoding_threads, n); } void set_default_directory (boost::filesystem::path d) { @@ -628,8 +636,10 @@ private: changed (prop); } - /** number of threads to use for J2K encoding on the local machine */ - int _num_local_encoding_threads; + /** number of threads which a master DoM should use for J2K encoding on the local machine */ + int _master_encoding_threads; + /** number of threads which a server should use for J2K encoding on the local machine */ + int _server_encoding_threads; /** default directory to put new films in */ boost::optional<boost::filesystem::path> _default_directory; /** base port number to use for J2K encoding servers; diff --git a/src/lib/encoder.cc b/src/lib/encoder.cc index e43325f58..276ef8d3a 100644 --- a/src/lib/encoder.cc +++ b/src/lib/encoder.cc @@ -414,7 +414,7 @@ Encoder::servers_list_changed () #endif if (!Config::instance()->only_servers_encode ()) { - for (int i = 0; i < Config::instance()->num_local_encoding_threads (); ++i) { + for (int i = 0; i < Config::instance()->master_encoding_threads (); ++i) { boost::thread* t = new boost::thread (boost::bind (&Encoder::encoder_thread, this, optional<EncodeServerDescription> ())); _threads.push_back (t); #ifdef BOOST_THREAD_PLATFORM_WIN32 diff --git a/src/lib/film.cc b/src/lib/film.cc index 82a40d5c4..218dc58ef 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -335,7 +335,7 @@ Film::make_dcp () if (Config::instance()->only_servers_encode ()) { LOG_GENERAL_NC ("0 threads: ONLY SERVERS SET TO ENCODE"); } else { - LOG_GENERAL ("%1 threads", Config::instance()->num_local_encoding_threads()); + LOG_GENERAL ("%1 threads", Config::instance()->master_encoding_threads()); } LOG_GENERAL ("J2K bandwidth %1", j2k_bandwidth()); diff --git a/src/lib/writer.cc b/src/lib/writer.cc index c507c5527..87cdac2d8 100644 --- a/src/lib/writer.cc +++ b/src/lib/writer.cc @@ -489,7 +489,7 @@ Writer::finish () shared_ptr<boost::asio::io_service::work> work (new boost::asio::io_service::work (service)); - int const threads = max (1, Config::instance()->num_local_encoding_threads ()); + int const threads = max (1, Config::instance()->master_encoding_threads ()); for (int i = 0; i < threads; ++i) { pool.create_thread (boost::bind (&boost::asio::io_service::run, &service)); |
