-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Open
Description
#include <iostream>
#include "ThreadPool.h"
class MyT {
public:
int run(int i) { return i; }
int init() { return 0; }
};
class MyClass {
void loopDoSomething() {}
void sayHello() { std::thread t(&MyClass::loopDoSomething, this); }
};
int main() {
ThreadPool pool(4);
MyT myt;
for (int i = 0; i < 6; ++i) {
// enqueue and store future
auto result = pool.enqueue([](int answer) { return answer; }, 42);
auto result2 = pool.enqueue(&MyT::run, &myt, i);
// get result from future
std::cout << result.get() << std::endl;
std::cout << result2.get() << std::endl;
std::cout << "\n" << std::endl;
}
return 0;
}
// if (0) {
// WorkFlow wf;
// __LOG_DEBUG("%p ", &wf);
// wf.Init(cfgs[0]);
// __LOG_DEBUG("%p ", &wf);
// std::thread t1(&WorkFlow::Run, &wf, &runtime_tensor, 1);
// t1.join();
// }Metadata
Metadata
Assignees
Labels
No labels