reference:
compare_exchange_weak / compare_exchange_strong
compare_exchange_strong; no spuriously fail
compare_exchange_weak; spuriously fail due to using timed lock; compare_exchange_weak is useful inside a loop;
A timed lock in C++ is a synchronization primitive, specifically a type of mutex, that allows a thread to attempt to acquire a lock for a specific maximum amount of time.
This is different from a standard std::mutex, where a thread calling lock() will block indefinitely until the mutex becomes available. A timed lock prevents a thread from getting stuck forever if another thread holds the lock and never releases it (due to a bug, for example).
In C++, the timed lock feature is provided by the std::timed_mutex class (and std::recursive_timed_mutex).
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.