38 int attr_ret = ::pthread_condattr_init(&attr_);
41 int shared_ret = ::pthread_condattr_setpshared(&attr_, PTHREAD_PROCESS_SHARED);
44 int cond_ret = ::pthread_cond_init(&cond_, &attr_);
59 while (notifiers_ > 0) {
66 int cond_ret = ::pthread_cond_destroy(&cond_);
69 int attr_ret = ::pthread_condattr_destroy(&attr_);
84 reinterpret_cast< std::atomic<uint32_t>*
>(address)->fetch_add(1U);
87 reinterpret_cast< std::atomic<uint32_t>*
>(address)->fetch_sub(1U);
96 int ret = ::pthread_cond_wait(&cond_, mutex_.
get_raw_mutex());
104 common_assert(scope);
105 struct timespec timeout;
108 timeout.tv_sec = now.tv_sec + (timeout_nanosec / 1000000000ULL);
109 timeout.tv_nsec = now.tv_usec * 1000ULL + timeout_nanosec % 1000000000ULL;
110 timeout.tv_sec += (timeout.tv_nsec) / 1000000000ULL;
111 timeout.tv_nsec %= 1000000000ULL;
115 int ret = ::pthread_cond_timedwait(&cond_, mutex_.
get_raw_mutex(), &timeout);
124 common_assert(scope);
130 while (waiters_ > 0) {
132 int ret = ::pthread_cond_signal(&cond_);
144 int ret = ::pthread_cond_signal(&cond_);
150 common_assert(scope);
156 int ret = ::pthread_cond_signal(&cond_);
void ugly_atomic_dec(uint32_t *address)
void wait(SharedMutexScope *scope)
Unconditionally wait for the event.
#define CXX11_NULLPTR
Used in public headers in place of "nullptr" of C++11.
void initialize(bool recursive=false)
Root package of FOEDUS (Fast Optimistic Engine for Data Unification Services).
pthread_mutex_t * get_raw_mutex()
void signal(SharedMutexScope *scope)
Unblock one waiter.
bool is_locked_by_me() const
SharedMutex * get_mutex() const
bool timedwait(SharedMutexScope *scope, uint64_t timeout_nanosec)
Wait for the event up to the given timeout.
void broadcast(SharedMutexScope *scope)
Unblock all waiters.
Auto-lock scope object for SharedMutex.
void spinlock_yield()
Invoke _mm_pause(), x86 PAUSE instruction, or something equivalent in the env.
Atomic fence methods and load/store with fences that work for both C++11/non-C++11 code...
void ugly_atomic_inc(uint32_t *address)
void memory_fence_acquire()
Equivalent to std::atomic_thread_fence(std::memory_order_acquire).
void broadcast_nolock()
Unblock all waiters without a mutex held by the signaller.
#define ASSERT_ND(x)
A warning-free wrapper macro of assert() that has no performance effect in release mode even when 'x'...
void memory_fence_acq_rel()
Equivalent to std::atomic_thread_fence(std::memory_order_acq_rel).