MySQL  8.0.24
Source Code Documentation
os0event.cc File Reference

The interface to the operating system condition variables. More...

#include "os0event.h"
#include <errno.h>
#include <time.h>
#include "ha_prototypes.h"
#include "ut0mutex.h"
#include "ut0new.h"
#include <list>

Classes

struct  os_event
 InnoDB condition variable. More...
 

Typedefs

typedef pthread_cond_t os_cond_t
 Native condition variable. More...
 
typedef std::list< os_event_t, ut_allocator< os_event_t > > os_event_list_t
 
typedef os_event_list_t::iterator event_iter_t
 

Functions

os_event_t os_event_create ()
 Creates an event semaphore, i.e., a semaphore which may just have two states: signaled and nonsignaled. More...
 
bool os_event_is_set (const os_event_t event)
 Check if the event is set. More...
 
void os_event_set (os_event_t event)
 Sets an event semaphore to the signaled state: lets waiting threads proceed. More...
 
bool os_event_try_set (os_event_t event)
 
int64_t os_event_reset (os_event_t event)
 Resets an event semaphore to the nonsignaled state. More...
 
ulint os_event_wait_time_low (os_event_t event, ulint time_in_usec, int64_t reset_sig_count)
 Waits for an event object until it is in the signaled state or a timeout is exceeded. More...
 
void os_event_wait_low (os_event_t event, int64_t reset_sig_count)
 Waits for an event object until it is in the signaled state. More...
 
void os_event_destroy (os_event_t &event)
 Frees an event object. More...
 
void os_event_global_init (void)
 Initializes support for os_event objects. More...
 
void os_event_global_destroy (void)
 Deinitializes support for os_event objects. More...
 

Variables

static const uint64_t MICROSECS_IN_A_SECOND = 1000000
 The number of microseconds in a second. More...
 
static const uint64_t NANOSECS_IN_A_SECOND = 1000 * MICROSECS_IN_A_SECOND
 The number of nanoseconds in a second. More...
 

Detailed Description

The interface to the operating system condition variables.

Created 2012-09-23 Sunny Bains

Typedef Documentation

◆ event_iter_t

typedef os_event_list_t::iterator event_iter_t

◆ os_cond_t

typedef pthread_cond_t os_cond_t

Native condition variable.

◆ os_event_list_t

Function Documentation

◆ os_event_create()

os_event_t os_event_create ( )

Creates an event semaphore, i.e., a semaphore which may just have two states: signaled and nonsignaled.

The created event is manual reset: it must be reset explicitly by calling sync_os_reset_event.

Returns
the event handle

On SuSE Linux we get spurious EBUSY from pthread_mutex_destroy() unless we grab and release the mutex here. Current OS version: openSUSE Leap 15.0 Linux xxx 4.12.14-lp150.12.25-default #1 SMP Thu Nov 1 06:14:23 UTC 2018 (3fcf457) x86_64 x86_64 x86_64 GNU/Linux

◆ os_event_destroy()

void os_event_destroy ( os_event_t event)

Frees an event object.

in/own: event to free

Parameters
eventin/own: event to free

◆ os_event_global_destroy()

void os_event_global_destroy ( void  )

Deinitializes support for os_event objects.

Must be called once, and after all os_event objects are destroyed. After it is called, no new os_event is allowed to be created.

◆ os_event_global_init()

void os_event_global_init ( void  )

Initializes support for os_event objects.

Must be called once, and before any os_event object is created.

◆ os_event_is_set()

bool os_event_is_set ( const os_event_t  event)

Check if the event is set.

Returns
true if set
Parameters
eventin: event to test

◆ os_event_reset()

int64_t os_event_reset ( os_event_t  event)

Resets an event semaphore to the nonsignaled state.

Waiting threads will stop to wait for the event. The return value should be passed to os_even_wait_low() if it is desired that this thread should not wait in case of an intervening call to os_event_set() between this os_event_reset() and the os_event_wait_low() call. See comments for os_event_wait_low().

Returns
current signal_count.
Parameters
eventin/out: event to reset

◆ os_event_set()

void os_event_set ( os_event_t  event)

Sets an event semaphore to the signaled state: lets waiting threads proceed.

in/out: event to set

Parameters
eventin/out: event to set

◆ os_event_try_set()

bool os_event_try_set ( os_event_t  event)

◆ os_event_wait_low()

void os_event_wait_low ( os_event_t  event,
int64_t  reset_sig_count 
)

Waits for an event object until it is in the signaled state.

Where such a scenario is possible, to avoid infinite wait, the value returned by os_event_reset() should be passed in as reset_sig_count.

Parameters
eventin: event to wait
reset_sig_countin: zero or the value returned by previous call of os_event_reset().

◆ os_event_wait_time_low()

ulint os_event_wait_time_low ( os_event_t  event,
ulint  time_in_usec,
int64_t  reset_sig_count 
)

Waits for an event object until it is in the signaled state or a timeout is exceeded.

Returns
0 if success, OS_SYNC_TIME_EXCEEDED if timeout was exceeded
Parameters
eventin/out: event to wait
time_in_usecin: timeout in microseconds, or OS_SYNC_INFINITE_TIME
reset_sig_countin: zero or the value returned by previous call of os_event_reset().

Variable Documentation

◆ MICROSECS_IN_A_SECOND

const uint64_t MICROSECS_IN_A_SECOND = 1000000
static

The number of microseconds in a second.

◆ NANOSECS_IN_A_SECOND

const uint64_t NANOSECS_IN_A_SECOND = 1000 * MICROSECS_IN_A_SECOND
static

The number of nanoseconds in a second.