diff --git a/job/queue.cpp b/job/queue.cpp index c58558bb..c2844ba1 100644 --- a/job/queue.cpp +++ b/job/queue.cpp @@ -16,12 +16,43 @@ #include "queue.hpp" +#include "../parse.hpp" #include "../raii.hpp" using util::job::queue; /////////////////////////////////////////////////////////////////////////////// +static unsigned +default_parallelism (void) +{ + if (auto var = getenv ("JOB_THREADS")) { + return util::parse (var); + } + + return std::thread::hardware_concurrency (); +} + + +//----------------------------------------------------------------------------- +static unsigned +default_depth (void) +{ + if (auto var = getenv ("JOB_DEPTH")) { + return util::parse (var); + } + + return 1024; +} + + +/////////////////////////////////////////////////////////////////////////////// +queue::queue (): + queue (default_parallelism (), default_depth ()) +{ ; } + + +//----------------------------------------------------------------------------- queue::queue (unsigned thread_count, unsigned pool_size): m_tasks { {}, util::pool {pool_size}, {}, {} diff --git a/job/queue.hpp b/job/queue.hpp index 0881563e..dde1817a 100644 --- a/job/queue.hpp +++ b/job/queue.hpp @@ -41,10 +41,7 @@ namespace util::job { class queue { public: - queue (): - queue (std::thread::hardware_concurrency (), 1024) - { ; } - + queue (); queue (unsigned thread_count, unsigned pool_size); ~queue ();