File tree Expand file tree Collapse file tree 3 files changed +4
-4
lines changed Expand file tree Collapse file tree 3 files changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -91,7 +91,7 @@ auto sum(ForwardIt first, ForwardIt last){
9191 std::size_t remainder = distance % num_threads;
9292
9393 // 存储每个线程的结果
94- std::vector<value_type>results( num_threads) ;
94+ std::vector<value_type> results { num_threads } ;
9595
9696 // 存储关联线程的线程对象
9797 std::vector<std::thread> threads;
@@ -120,7 +120,7 @@ auto sum(ForwardIt first, ForwardIt last){
120120}
121121```
122122
123- > [运行](https://godbolt.org/z/8oq3MnvT5 )测试。
123+ > [运行](https://godbolt.org/z/MdrP98o13 )测试。
124124
125125我们写了这样一个求和函数 `sum`,接受两个迭代器计算它们范围中对象的和。
126126
Original file line number Diff line number Diff line change @@ -371,7 +371,7 @@ std::size_t n{};
371371
372372void f(){
373373 std::lock_guard<std::mutex> lc1{ m1 };
374- std::lock_guard<std::mutex> lc2{ m2 };;
374+ std::lock_guard<std::mutex> lc2{ m2 };
375375 ++n;
376376}
377377void f2() {
Original file line number Diff line number Diff line change 1212
1313- Qt 实现异步任务的示例
1414
15- - 其它 C++20 同步设施:信号两 、闩与屏障
15+ - 其它 C++20 同步设施:信号量 、闩与屏障
1616
1717本章将讨论如何使用条件变量等待事件,介绍 future 等标准库设施用作同步操作,使用Qt+CMake 构建一个项目展示多线程的必要性,介绍 C++20 引入的新的同步设施。
1818
You can’t perform that action at this time.
0 commit comments