#pragma once #include #include #include #include #include using namespace std; class Scheduler { struct Job { function callback; Job(const function callback) : callback(callback) {} }; bool verbose; queue jobs; bool finishFlag = false; mutex commMut; bool hasJoined = false; vector workers; void workerEntry(bool verbose); public: const int nthreads; Scheduler(bool verbose, int nthreads); ~Scheduler(); // func is run in child thread void submit(const function &func); void finish(); };