gpt4 book ai didi

c++ - sig_atomic_t 和 std::atomic<> 可以互换吗?

转载 作者:IT老高 更新时间:2023-10-28 22:59:28 26 4
gpt4 key购买 nike

根据标题。我可以使用 std::atomic<>在信号处理程序中或执行sig_atomic_t提供其他编译器功能?

最佳答案

n3376 1.9/6

When the processing of the abstract machine is interrupted by receipt of a signal, the values of objects whichare neither

— of type volatile std::sig_atomic_t nor

— lock-free atomic objects (29.4)

are unspecified during the execution of the signal handler, and the value of any object not in either ofthese two categories that is modified by the handler becomes undefined.

无锁 29.4/1,2

The ATOMIC_..._LOCK_FREE macros indicate the lock-free property of the corresponding atomic types, withthe signed and unsigned variants grouped together. The properties also apply to the corresponding (partial)specializations of the atomic template. A value of 0 indicates that the types are never lock-free. A value of1 indicates that the types are sometimes lock-free. A value of 2 indicates that the types are always lock-free.

The function atomic_is_lock_free (29.6) indicates whether the object is lock-free. In any given programexecution, the result of the lock-free query shall be consistent for all pointers of the same type.

关于c++ - sig_atomic_t 和 std::atomic<> 可以互换吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15949036/

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