diff --git a/test/src/cpp11/thread_usage.cpp b/test/src/cpp11/thread_usage.cpp index 22a2530..93a0154 100644 --- a/test/src/cpp11/thread_usage.cpp +++ b/test/src/cpp11/thread_usage.cpp @@ -78,7 +78,7 @@ void do_print_id(int id) { } void go(){ - gReady = true; + gReady = false; gCv.notify_all(); // 唤醒所有线程. } @@ -93,6 +93,10 @@ int TestConditionVariable() { for (int i = 0; i < 10; ++i) threads[i] = std::thread(do_print_id, i); std::cout << "10 threads ready to race...\n"; + Sleep(1000); + go_once(); + go_once(); + go_once(); go_once(); for (auto & th:threads) @@ -252,6 +256,12 @@ class ASyncProcess { ret = t(args...); }); } + ASyncProcess(Function t,Ret &ret){ + std::cout<<"ASyncProcess construct"< int test2(R(&f)(Args...), R& ret_param, Args... args) { ret_param = f(args...); @@ -279,10 +287,10 @@ int test2(void(&f)(Args...), Args... args) return 0; } - int ss(int p,int w){ return 1; } + int main() { TestConditionVariable(); @@ -293,6 +301,5 @@ int main() },result,22); getchar(); std::cout<