}
void useGlobal() noexcept {
- state_ = State::GLOBAL_TRANSITION;
+ std::array<RCURefCount*, 1> ptrs{{this}};
+ useGlobal(ptrs);
+ }
+
+ template <typename Container>
+ static void useGlobal(const Container& refCountPtrs) {
+ for (auto refCountPtr : refCountPtrs) {
+ refCountPtr->state_ = State::GLOBAL_TRANSITION;
+ }
synchronize_rcu();
// At this point everyone is using the global count
- auto accessor = localCount_.accessAllThreads();
- for (auto& count : accessor) {
- count.collect();
- }
+ for (auto refCountPtr : refCountPtrs) {
+ auto accessor = refCountPtr->localCount_.accessAllThreads();
+ for (auto& count : accessor) {
+ count.collect();
+ }
- state_ = State::GLOBAL;
+ refCountPtr->state_ = State::GLOBAL;
+ }
synchronize_rcu();
// After this ++ or -- can return 0.