便携式 c++原子交换(Windows - GNU/Linux - MacOSX)

发布于 2024-08-23 08:24:30 字数 148 浏览 2 评论 0原文

是否有免费的可移植(Windows、GNU/Linux 和 MacOSX)库提供无锁原子交换功能

如果没有,如何在每个平台上实施? (带有 VC++ 或 g++ 的 x86)

谢谢

Is there free a portable (Windows, GNU/Linux & MacOSX) library providing a lock-free atomic swap function?

If not, how would it be implemented for each of these platforms? (x86 with VC++ or g++)

Thanks

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

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

发布评论

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

评论(3

哭了丶谁疼 2024-08-30 08:24:30

无锁库正在等待审核www.boost.org" rel="nofollow noreferrer">提升。另外,如果您深入研究Boost智能指针的源代码在库中,您会发现针对多个平台的内联原子操作。另一种 - Intel Threading Building Blocks 实现了 atomic 模板。

There's a lock-free library pending review in boost. Also if you dig into source of boost smart pointers library you will find atomic ops inlined for multiple platforms. Another one - Intel Threading Building Blocks has implementation of atomic<> template.

一抹微笑 2024-08-30 08:24:30

就看你想换什么了。在 x86 的汇编器中,您可能能够获得“几乎”原子异或交换,否则我会采用一些使用锁定的解决方案,这在 Win32/{Linux,Darwin} 上会有所不同。

如果您正在寻找库,请查看 APR (Apache Portable Runtime) - http://apr.apache。组织/

Depends what you want to swap. In assembler for x86 you might be able to get a "nearly" atomic xor swap, otherwise I'd go with some solution that uses locking, which will differ on Win32/{Linux,Darwin}.

If you are looking for a library, have a look at APR (Apache Portable Runtime) - http://apr.apache.org/

拿命拼未来 2024-08-30 08:24:30

Boost 有一组宏用于促进锁定-以便携的方式自由操作。

Boost has a set of macros for facilitating lock-free operations in a portable way.

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