#pragma once #include #include #include struct process { process(const std::string& k, const std::string& command): key{k}, child{command} {} std::string key; boost::process::child child; }; // runs a number of processes in parallel, with an upper limit class ProcessRunner { public: ProcessRunner(); void spawn(const std::string& key, const std::string& command); bool empty(); // number of running processes is zero bool full(); // number of running processes equals maximum int wait_one(std::string& key); // returns exit code, and key via reference int wait_all(); size_t running(); // number of running processes in queue size_t finished(); // number of finished processes in queue private: int _max_number_of_processes; std::deque _processes; };