We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
不同长度的整型使用这些原子操作接口时得到的结果不正确。 比如:atomic_flag_test_and_set函数(内部代码:InterlockedCompareExchange((LONG*)&p->_Value, 1, 0))调用后并不能让atomic_flag置1。
atomic_flag_test_and_set
InterlockedCompareExchange((LONG*)&p->_Value, 1, 0)
还有这些原子操作接口在不同平台下的返回值不同。比如我用来实现引用计数的代码:
if (ATOMIC_DEC(&ref->refcnt) == 1) { release_cb(ref); }
在linux下,ATOMIC_DEC返回的减少之前的值,而在windows下返回的是减少之后的值,这导致这段代码在Windows下不正确。
ATOMIC_DEC
The text was updated successfully, but these errors were encountered:
libhv里确实没有用到ATOMIC_INC、ATOMIC_DEC的返回值,这里windows下可以考虑使用InterlockedAdd,而不是InterlockedIncrement/InterlockedDecrement,应该就可以了吧
Sorry, something went wrong.
No branches or pull requests
不同长度的整型使用这些原子操作接口时得到的结果不正确。
比如:
atomic_flag_test_and_set
函数(内部代码:InterlockedCompareExchange((LONG*)&p->_Value, 1, 0)
)调用后并不能让atomic_flag置1。还有这些原子操作接口在不同平台下的返回值不同。比如我用来实现引用计数的代码:
在linux下,
ATOMIC_DEC
返回的减少之前的值,而在windows下返回的是减少之后的值,这导致这段代码在Windows下不正确。The text was updated successfully, but these errors were encountered: