made concurrent_table::thread_counter static

This commit is contained in:
joaquintides
2023-03-29 16:45:15 +02:00
parent 7b1af37b9c
commit 4482031329

View File

@ -656,7 +656,6 @@ private:
shared_lock_guard shared_access()const shared_lock_guard shared_access()const
{ {
// TODO: make this more sophisticated (even distribution)
thread_local auto id=(++thread_counter)%mutexes.size(); thread_local auto id=(++thread_counter)%mutexes.size();
return shared_lock_guard{mutexes[id]}; return shared_lock_guard{mutexes[id]};
@ -1051,11 +1050,13 @@ private:
} }
#endif #endif
/* TODO: thread_counter should be static */ static std::atomic<std::size_t> thread_counter;
mutable std::atomic<unsigned int> thread_counter{0};
mutable multimutex_type mutexes; mutable multimutex_type mutexes;
}; };
template<typename T,typename H,typename P,typename A>
std::atomic<std::size_t> concurrent_table<T,H,P,A>::thread_counter=0;
#if defined(BOOST_MSVC) #if defined(BOOST_MSVC)
#pragma warning(pop) /* C4714 */ #pragma warning(pop) /* C4714 */
#endif #endif