11#include <condition_variable>
111 }
while (!
threadInfos.compare_exchange_weak(head,
this));
130 std::atomic<RCUInfos *> *ptr;
137 if (current ==
this) {
141 assert(current !=
nullptr);
142 ptr = ¤t->
next;
154 if (!ptr->compare_exchange_strong(current,
next.load())) {
185 static std::condition_variable cond;
192 }
while (!cond.wait_for(lock, std::chrono::microseconds(1), [&] {
193 return cleanups.empty() && hasSyncedTo(syncRev);
221 if (it->first > syncedTo) {
226 while (it !=
cleanups.end() && it->first <= syncedTo) {
228 auto fun = std::move(it->second);
236 uint64_t syncedTo =
revision.load();
242 while (current !=
nullptr) {
243 syncedTo = std::min(syncedTo, current->
state.load());
244 if (syncedTo < cutoff) {
248 current = current->
next.load();
RCUCleanupGuard(RCUInfos *infosIn)
uint64_t hasSyncedTo(uint64_t cutoff=UNLOCKED)
std::atomic< RCUInfos * > next
static thread_local RCUInfos infos
std::map< uint64_t, std::function< void()> > cleanups
std::atomic< uint64_t > state
static std::atomic< uint64_t > revision
static std::atomic< RCUInfos * > threadInfos
We maintain a linked list of all the RCUInfos for each active thread.
static RecursiveMutex csThreadInfosDelete
static constexpr int RCU_ACTIVE_LOOP_COUNT
How many time a busy loop runs before yelding.
#define WAIT_LOCK(cs, name)