diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2010-12-31 00:42:46 +0100 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2010-12-31 00:42:46 +0100 |
commit | b439fcd1916cef267bde32f3424d8311519d3d16 (patch) | |
tree | 9335911a159dee74ff6c410db5e3ca3167b84218 | |
parent | 9a5138ce981697e243fa0de2bc2668eaa80efb76 (diff) |
Read number of threads to start from audist.threads, defaulting to 10.
-rw-r--r-- | config.cpp | 1 | ||||
-rw-r--r-- | main.cpp | 5 |
2 files changed, 4 insertions, 2 deletions
@@ -11,6 +11,7 @@ void config::init() { desc.add_options() ("audist.music_root", po::value<std::string>(), "music root") ("audist.httpd_port", po::value<int>()->default_value(8000), "httpd port") + ("audist.threads", po::value<std::size_t>()->default_value(10), "threads") ("audist.database", po::value<std::string>(), "database string") ; std::ifstream is("audist.conf", std::ios::in); @@ -20,12 +20,13 @@ int main(int argc, char **argv) { HTTP::Server httpd(io_service, tcp::endpoint(tcp::v6(), config::vm["audist.httpd_port"].as<int>())); + std::size_t num_threads = config::vm["audist.threads"].as<std::size_t>(); std::vector<boost::shared_ptr<boost::thread> > threads; - for(std::size_t i = 0; i < 10; i++) { + for(std::size_t i = 0; i < num_threads; i++) { boost::shared_ptr<boost::thread> thread(new boost::thread(boost::bind(&boost::asio::io_service::run, &io_service))); threads.push_back(thread); } - for(std::size_t i = 0; i < 10; i++) { + for(std::size_t i = 0; i < num_threads; i++) { threads[i]->join(); } } catch(std::exception& e) { |