gpt4 book ai didi

c++ - 调用 gcc _without_ -pthread 有什么好处?

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:51:40 26 4
gpt4 key购买 nike

我们知道添加-pthread makes GCC use reentrant/thread-safe code (编译 C/C++ 代码时)。虽然我想如果您允许不可重入,您确实可以在这里和那里节省几个周期 - 我想知道总是指定 -pthread 是否有任何实际优势。有吗?

最佳答案

一个例子:std::shared_ptr 的 libstdc++ 实现 doesn't use locking when compiled without -pthread ,如果您在单线程环境中大量使用共享指针,这可以大大提高性能。

关于c++ - 调用 gcc _without_ -pthread 有什么好处?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36079938/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com