From 218e49fa7b87ed6a337fbf0d47998fe13e6b774c Mon Sep 17 00:00:00 2001 From: zcy <290198252@qq.com> Date: Mon, 29 Nov 2021 15:33:44 +0800 Subject: [PATCH] no message --- test/src/cpp11/thread_usage.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) 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<