8 #include "gtest/gtest_prod.h"
13 #ifdef CVMFS_NAMESPACE_GUARD
14 namespace CVMFS_NAMESPACE_GUARD {
26 FRIEND_TEST(T_Fence, Basics);
30 atomic_init64(&counter_);
31 atomic_init32(&blocking_);
35 while (atomic_read32(&blocking_)) {
38 atomic_inc64(&counter_);
41 void Leave() { atomic_dec64(&counter_); }
43 void Close() { atomic_cas32(&blocking_, 0, 1); }
50 while (atomic_read64(&counter_) > 0) {
55 void Open() { atomic_cas32(&blocking_, 1, 0); }
58 static const unsigned kBusyWaitBackoffMs = 100;
85 #ifdef CVMFS_NAMESPACE_GUARD
89 #endif // CVMFS_FENCE_H_
void SafeSleepMs(const unsigned ms)