1#ifndef THR_COND_INCLUDED
2#define THR_COND_INCLUDED
61static DWORD get_milliseconds(
const struct timespec *abstime) {
66 ulonglong future = abstime->tv_sec * 1000 + abstime->tv_nsec / 1000000;
69 if (future < now)
return 0;
70 return (DWORD)(future - now);
76 InitializeConditionVariable(cond);
80 return pthread_cond_init(cond,
nullptr);
88 return pthread_cond_destroy(cond);
94 const struct timespec *abstime) {
96 DWORD
timeout = get_milliseconds(abstime);
100 return pthread_cond_timedwait(cond, mutex, abstime);
106 if (!SleepConditionVariableCS(cond, mutex, INFINITE))
return ETIMEDOUT;
109 return pthread_cond_wait(cond, mutex);
115 WakeConditionVariable(cond);
118 return pthread_cond_signal(cond);
124 WakeAllConditionVariable(cond);
127 return pthread_cond_broadcast(cond);
134int safe_cond_timedwait(
native_cond_t *cond, safe_mutex_t *mp,
135 const struct timespec *abstime,
const char *
file,
140 const struct timespec *abstime
160 return safe_cond_wait(cond, mp->m_u.m_safe_ptr,
file, line);
unsigned long long int ulonglong
Definition: my_inttypes.h:56
Defines for getting and processing the current system type programmatically.
unsigned long long int my_getsystime()
Get high-resolution time.
Definition: my_systime.h:102
Defines to make different thread packages compatible.
#define ETIMEDOUT
Definition: my_thread.h:48
static bool timeout(bool(*wait_condition)())
Timeout function.
Definition: log0meb.cc:496
Definition: thr_mutex_bits.h:61
static int native_cond_init(native_cond_t *cond)
Definition: thr_cond.h:74
static int native_cond_wait(native_cond_t *cond, native_mutex_t *mutex)
Definition: thr_cond.h:104
static int native_cond_broadcast(native_cond_t *cond)
Definition: thr_cond.h:122
static int my_cond_timedwait(native_cond_t *cond, my_mutex_t *mp, const struct timespec *abstime)
Definition: thr_cond.h:139
static int my_cond_wait(native_cond_t *cond, my_mutex_t *mp)
Definition: thr_cond.h:153
static int native_cond_destroy(native_cond_t *cond)
Definition: thr_cond.h:84
static int native_cond_signal(native_cond_t *cond)
Definition: thr_cond.h:113
static int native_cond_timedwait(native_cond_t *cond, native_mutex_t *mutex, const struct timespec *abstime)
Definition: thr_cond.h:92
MySQL condition variable implementation.
pthread_cond_t native_cond_t
Definition: thr_cond_bits.h:46
MySQL mutex implementation.
pthread_mutex_t native_mutex_t
Definition: thr_mutex_bits.h:55
Include file for Sun RPC to compile out of the box.
unsigned int uint
Definition: uca9-dump.cc:75
native_mutex_t m_native
Definition: thr_mutex_bits.h:63
safe_mutex_t * m_safe_ptr
Definition: thr_mutex_bits.h:64