Visual Studio 11 中的 c++11 thread_local 关键字支持

发布于 2024-12-25 14:40:39 字数 546 浏览 5 评论 0原文

因此,有一个 支持的 c++11 功能列表视觉工作室

thread_local 支持被标记为部分。我在这里找不到部分支持到底意味着什么的解释。他们只是别名 __declspec(thread) 吗?

我可以只使用 boost::thread_specific_ptr,但似乎有一些报告 boost::thread_specific_ptr 很慢。这可能是真的,也可能不是。

具体来说,我希望在最新的 linux+gcc 和 windows+msvc 上的 x86/x64 上实现快速 TLS。快速意味着尽可能不进行系统调用(我认为这对于上述平台是可能的。)

So there's a list of c++11 features supported by visual studio.

thread_local support is marked as partial. I was unable to find an explanation of what exactly partial support means here. Did they just alias __declspec(thread)?

I could just use boost::thread_specific_ptr, but there seem to be some reports that boost::thread_specific_ptr is slow. That may or may not be true.

Specifically I want fast TLS on x86/x64 on the most recent linux+gcc and windows+msvc. Fast meaning no system calls where possible (I think this is possible for the platforms above.)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

↘紸啶 2025-01-01 14:40:39

所以我深入研究了 thread_local 语义。 gcc 的 __thread 和 msvc 的 __declspec(thread) 彼此和 thread_local 具有相同的语义(动态初始化除外,这可能已或可能尚未成为标准。)所以这对于我的用例来说实际上不是问题。我将只进行一个定义,为一个或另一个特定于平台的属性添加别名。

So I did some digging into thread_local semantics. gcc's __thread and msvc's __declspec(thread) have the same semantics as each other and thread_local (dynamic initialization aside, which may or may not have made it into the standard yet.) So this is really a non-issue for my use case. I'll just make a define that aliases one or the other platform specific attribute.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文