c++ - 为什么没有 InterlockedExchange Subtract 64?

标签 c++ windows winapi

在WindowsAPI上,有

  • InterlockedExchangeAdd
  • InterlockedExchangeAdd64
  • InterlockedExchangeSubtract

为什么没有InterlockedExchangeSubtract64

我想对 64 位值 (LONGLONG) 执行原子操作,而不必使用互斥锁。

最佳答案

简单地否定您传递给 InterlockedExchangeAdd64 的操作数。换句话说,利用 x - y 等于 x + (-y) 这一事实。

关于c++ - 为什么没有 InterlockedExchange Subtract 64?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21099929/

相关文章:

c++ - std::unique_ptr ostream 插入器

c++ - 使用 boost locale : different behaviour on windows and linux 进行字符串转换

python - 检查应用程序是如何启动的?

C++:如何生成随机数,同时从给定缓存中排除数字

c++ - 在 OpenGL 引擎中组织 GLSL 着色器

c++ - Linux C++ 将 Boost 编译到我的程序中

python - Windows 上 Python (v3.0) 中的环境变量

delphi - 当 TComboBox 使用 csOwnerDrawFixed 或 csOwnerDrawVariable 时如何模拟 Windows 主题行为?

winapi - 为什么 GetWindowRgn 在 Vista 上失败?

c++ - 链接到 DLL 的未处理异常