Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <queue>
- #include <future>
- class ThreadManager {
- std::queue<std::function<void()>> _tasks;
- public:
- template<class F>
- void futureTask(F&& f) {
- // the idea here is to package a task, and push it
- _tasks.push([] {});
- }
- };
- class Runner {
- public:
- Runner() {
- ThreadManager tm;
- auto runFn = std::bind(&Runner::run, this);
- tm.futureTask(std::move(runFn));
- }
- void run() {
- // do some stuff
- }
- };
- int main() {
- Runner r;
- r.run();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement