基于 C++ 11 实现线程池
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

main.cpp 285B

12345678910111213141516171819
  1. #include <iostream>
  2. #include <future>
  3. #include "ThreadPool.h"
  4. using namespace std;
  5. int sum1(int a, int b) {
  6. return a + b;
  7. }
  8. int main() {
  9. ThreadPool pool;
  10. pool.start();
  11. future<int> res = pool.submitTask(sum1, 10, 20);
  12. cout << res.get() << endl;
  13. return 0;
  14. }