From b439fcd1916cef267bde32f3424d8311519d3d16 Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Fri, 31 Dec 2010 00:42:46 +0100 Subject: Read number of threads to start from audist.threads, defaulting to 10. --- config.cpp | 1 + main.cpp | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/config.cpp b/config.cpp index 9376f10..e59f2c2 100644 --- a/config.cpp +++ b/config.cpp @@ -11,6 +11,7 @@ void config::init() { desc.add_options() ("audist.music_root", po::value(), "music root") ("audist.httpd_port", po::value()->default_value(8000), "httpd port") + ("audist.threads", po::value()->default_value(10), "threads") ("audist.database", po::value(), "database string") ; std::ifstream is("audist.conf", std::ios::in); diff --git a/main.cpp b/main.cpp index dc96f5a..28b846b 100644 --- a/main.cpp +++ b/main.cpp @@ -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())); + std::size_t num_threads = config::vm["audist.threads"].as(); std::vector > threads; - for(std::size_t i = 0; i < 10; i++) { + for(std::size_t i = 0; i < num_threads; i++) { boost::shared_ptr 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) { -- cgit v1.2.3