You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Thread 1:voidawesome_function() {
if (my_map.empty()) { //! call size() internally;
}
}
//! Thread 2:voidanother_awesome_function() {
//! Clear internally lock size_ with a mutex data race occur in the thread 1 because size_ is not locked
my_map.clear(); //!
}
Potential solution (size() function can lock size_):
folly/folly/concurrency/detail/ConcurrentHashMap-detail.h
Line 247 in f6ac9ac
Hello the following use case will data-race:
Potential solution (size() function can lock size_):
Where size_ is locked ?
Another solution can be to have an std::atomicstd::size_t and returning size_.load(); when necessary.
The text was updated successfully, but these errors were encountered: