File tree 2 files changed +2
-2
lines changed
2 files changed +2
-2
lines changed Original file line number Diff line number Diff line change @@ -899,7 +899,7 @@ stop_source _Ssource;
899
899
900
900
首先要明确,C++ 的 ` std::jthread ` 提供的线程停止功能并不同于常见的 POSIX 函数 [ ` pthread_cancel ` ] ( https://pubs.opengroup.org/onlinepubs/9699919799/ ) 。` pthread_cancel ` 是一种发送取消请求的函数,但并不是强制性的线程终止方式。目标线程的可取消性状态和类型决定了取消何时生效。当取消被执行时,进行清理和终止线程[ ^ 2 ] 。
901
901
902
- ` std::jthread ` 所谓的线程停止只是一种基于用户代码的控制机制,而不是一种强制性的线程终止 。使用 ` std::stop_source ` 和 [ ` std::stop_token ` ] ( https://zh.cppreference.com/w/cpp/thread/stop_token ) 提供了一种优雅地请求线程停止的方式,** 但实际上停止的决定和实现都由用户代码来完成** 。
902
+ ` std::jthread ` 所谓的线程停止只是一种 ** 基于用户代码的控制机制 ** ,而不是一种与操作系统系统有关系的线程终止 。使用 ` std::stop_source ` 和 [ ` std::stop_token ` ] ( https://zh.cppreference.com/w/cpp/thread/stop_token ) 提供了一种优雅地请求线程停止的方式,** 但实际上停止的决定和实现都由用户代码来完成** 。
903
903
904
904
``` cpp
905
905
using namespace std ::literals::chrono_literals;
Original file line number Diff line number Diff line change @@ -1171,7 +1171,7 @@ int main() {
1171
1171
[主] 获得信号
1172
1172
```
1173
1173
1174
- [ ` acquire ` ] ( https://zh.cppreference.com/w/cpp/thread/counting_semaphore/acquire ) 函数就是我们先前说的“* 等待* ”(减少计数), ` release ` 函数就是"释放"(增加计数 )。
1174
+ [ ` acquire ` ] ( https://zh.cppreference.com/w/cpp/thread/counting_semaphore/acquire ) 函数就是我们先前说的“* 等待* ”(** 原子 ** 地减少计数), [ ` release ` ] ( https://zh.cppreference.com/w/cpp/thread/counting_semaphore/release ) 函数就是"释放"(** 原子 ** 地增加计数 )。
1175
1175
1176
1176
---
1177
1177
You can’t perform that action at this time.
0 commit comments