bool compare_exchange_strong( Ty& Exp, Ty Value, memory_order Order1, memory_order Order2 ) volatile _NOEXCEPT; bool compare_exchange_strong( Ty& Exp, Ty Value, memory_order Order1, memory_order Order2 ) _NOEXCEPT; bool compare_exchange_strong( Ty& Exp, Ty Value, memory_order Order1 ...
bool compare_exchange_strong(T& expected, T desired, memory_order success = memory_order_seq_cst, memory_order failure = memory_order_seq_cst) noexcept; 参数说明: expected:期望值的地址,也是输入参数,表示要比较的值; desired:新值,也是输入参数,表示期望值等于该值时需要替换的值; success:表示函数...
bool atomic_compare_exchange_strong_explicit(volatileA*object,C*expected,Cdesired, memory_ordersuccess, memory_orderfailure) noexcept; bool atomic_compare_exchange_strong_explicit(A*object,C*expected,Cdesired, memory_ordersuccess, memory_orderfailure) noexcept; ...
template <class T> bool atomic_compare_exchange_strong (volatile atomic<T>* obj, T* expected, T val) noexcept; template <class T> bool atomic_compare_exchange_strong (atomic<T>* obj, T* expected, T val) noexcept; overloads (2) bool atomic_compare_exchange_strong (volatile A* obj,...
bool atomic_compare_exchange_strong(A * object, C * expected, C desired) noexcept; Parameters A One of the atomic types. C The corresponding non-atomic type of A. object The pointer that points to the atomic object to test and modify. expected The pointer that points to the value expecte...
template <class Ty> inline bool atomic_compare_exchange_strong( volatile atomic<Ty> *Atom, Ty *Exp, Ty Value ) _NOEXCEPT; template <class Ty> inline bool atomic_compare_exchange_strong( atomic<Ty> *Atom, Ty *Exp, TyValue ) _NOEXCEPT; 参数 Atom 若要存储类型 Ty的值 atomic 对象的指针...
在下文中一共展示了atomic::compare_exchange_strong方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。 示例1: try_lock ▲点赞 6▼ booltry_lock(){size_tbad_id =-1;autoThisID = _hash(std::this_thread::get...
atomic_compare_exchange 分为两个版本 atomic_compare_exchange_strong 和 atomic_compare_exchange_weak,语义如下 boolatomic_compare_exchange(volatileA *obj, C*expected, C desired, memory_order succ, memory_order fail ); { fence_before(succ);//fence 1if(*obj ==expected) ...
(mtx); int old_value = data; data += val; return old_value; } int exchange(int val) { std::lock_guard lk(mtx); int old_value = data; data = val; return old_value; } bool compare_exchange_strong(int &old_value, int val) { std::lock_guard lk(mtx); if ( data == old_...
atomic::compare_exchange_strong对*this 执行原子比较和交换操作。C++ 复制 bool compare_exchange_strong( Ty& Exp, Ty Value, memory_order Order1, memory_order Order2 ) volatile noexcept; bool compare_exchange_strong( Ty& Exp, Ty Value, memory_order Order1, memory_order Order2 ) noexcept; ...