1#ifndef THR_RWLOCK_INCLUDED
2#define THR_RWLOCK_INCLUDED
61 InitializeSRWLock(&rwp->srwlock);
62 rwp->have_exclusive_srwlock =
false;
66 return pthread_rwlock_init(rwp,
nullptr);
74 return pthread_rwlock_destroy(rwp);
80 AcquireSRWLockShared(&rwp->srwlock);
83 return pthread_rwlock_rdlock(rwp);
89 if (!TryAcquireSRWLockShared(&rwp->srwlock))
return EBUSY;
92 return pthread_rwlock_tryrdlock(rwp);
98 AcquireSRWLockExclusive(&rwp->srwlock);
99 rwp->have_exclusive_srwlock =
true;
102 return pthread_rwlock_wrlock(rwp);
108 if (!TryAcquireSRWLockExclusive(&rwp->srwlock))
return EBUSY;
109 rwp->have_exclusive_srwlock =
true;
112 return pthread_rwlock_trywrlock(rwp);
118 if (rwp->have_exclusive_srwlock) {
119 rwp->have_exclusive_srwlock =
false;
120 ReleaseSRWLockExclusive(&rwp->srwlock);
122 ReleaseSRWLockShared(&rwp->srwlock);
125 return pthread_rwlock_unlock(rwp);
136static inline void rw_pr_lock_assert_write_owner(
const rw_pr_lock_t *rwlock) {
141static inline void rw_pr_lock_assert_not_write_owner(
Some integer typedefs for easier portability.
Defines to make different thread packages compatible.
static my_thread_t my_thread_self()
Definition: my_thread.h:75
static int my_thread_equal(my_thread_t t1, my_thread_t t2)
Definition: my_thread.h:83
Portable implementation of special type of read-write locks.
Definition: thr_rwlock_bits.h:95
my_thread_t writer_thread
Thread holding wr-lock (for debug purposes only).
Definition: thr_rwlock_bits.h:113
bool active_writer
Indicates whether there is an active writer.
Definition: thr_rwlock_bits.h:111
MySQL condition variable implementation.
MySQL mutex implementation.
static int native_rw_init(native_rw_lock_t *rwp)
Definition: thr_rwlock.h:59
int rw_pr_wrlock(rw_pr_lock_t *)
Definition: thr_rwlock.cc:67
int rw_pr_destroy(rw_pr_lock_t *)
Definition: thr_rwlock.cc:48
static int native_rw_trywrlock(native_rw_lock_t *rwp)
Definition: thr_rwlock.h:106
int rw_pr_rdlock(rw_pr_lock_t *)
Definition: thr_rwlock.cc:54
static int native_rw_tryrdlock(native_rw_lock_t *rwp)
Definition: thr_rwlock.h:87
static int native_rw_destroy(native_rw_lock_t *rwp)
Definition: thr_rwlock.h:70
int rw_pr_unlock(rw_pr_lock_t *)
Definition: thr_rwlock.cc:100
static int native_rw_rdlock(native_rw_lock_t *rwp)
Definition: thr_rwlock.h:78
static int native_rw_unlock(native_rw_lock_t *rwp)
Definition: thr_rwlock.h:116
static int native_rw_wrlock(native_rw_lock_t *rwp)
Definition: thr_rwlock.h:96
int rw_pr_init(rw_pr_lock_t *)
Definition: thr_rwlock.cc:36
pthread_rwlock_t native_rw_lock_t
Definition: thr_rwlock_bits.h:61