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