MySQL 8.0.39
Source Code Documentation
TTASEventMutex< Policy > Struct Template Reference

#include <ib0mutex.h>

Public Types

typedef Policy< TTASEventMutexMutexPolicy
 

Public Member Functions

 TTASEventMutex () 1
 
 ~TTASEventMutex () 1
 
std::thread::id peek_owner () const 1
 If the lock is locked, returns the current owner of the lock, otherwise returns the default std::thread::id{}. More...
 
void init (latch_id_t id, const char *filename, uint32_t line) 1
 Called when the mutex is "created". More...
 
void destroy () 1
 This is the real destructor. More...
 
bool try_lock () 1
 Try and lock the mutex. More...
 
void exit () 1
 Release the mutex. More...
 
void enter (uint32_t max_spins, uint32_t max_delay, const char *filename, uint32_t line) 1
 Acquire the mutex. More...
 
os_event_t event () 1
 The event that the mutex will wait in sync0arr.cc. More...
 
bool is_locked () const 1
 
bool is_owned () const 1
 
MutexPolicypolicy () 1
 
const MutexPolicypolicy () const 1
 

Private Member Functions

bool wait (const char *filename, uint32_t line, uint32_t spin) 1
 Wait in the sync array. More...
 
bool is_free (uint32_t max_spins, uint32_t max_delay, uint32_t &n_spins) const 1
 Spin and wait for the mutex to become free. More...
 
void spin_and_try_lock (uint32_t max_spins, uint32_t max_delay, const char *filename, uint32_t line) 1
 Spin while trying to acquire the mutex. More...
 
void set_waiters () 1
 Note that there are threads waiting on the mutex. More...
 
void clear_waiters () 1
 Note that there are no threads waiting on the mutex. More...
 
void signal () 1
 Wakeup any waiting thread(s). More...
 
 TTASEventMutex (TTASEventMutex &&)=delete
 Disable copying. More...
 
 TTASEventMutex (const TTASEventMutex &)=delete
 
TTASEventMutexoperator= (TTASEventMutex &&)=delete
 
TTASEventMutexoperator= (const TTASEventMutex &)=delete
 

Private Attributes

std::atomic< std::thread::idm_owner {std::thread::id{}}
 Set to owner's thread's id when locked, and reset to the default std::thread::id{} when unlocked. More...
 
os_event_t m_event {}
 Used by sync0arr.cc for the wait queue. More...
 
MutexPolicy m_policy
 Policy data. More...
 
std::atomic_bool m_waiters {false}
 true if there are (or may be) threads waiting in the global wait array for this mutex to be released. More...
 

Member Typedef Documentation

◆ MutexPolicy

template<template< typename > class Policy = NoPolicy>
typedef Policy<TTASEventMutex> TTASEventMutex< Policy >::MutexPolicy

Constructor & Destructor Documentation

◆ TTASEventMutex() [1/3]

template<template< typename > class Policy = NoPolicy>
TTASEventMutex< Policy >::TTASEventMutex ( )
inline

◆ ~TTASEventMutex()

template<template< typename > class Policy = NoPolicy>
TTASEventMutex< Policy >::~TTASEventMutex ( )
inline

◆ TTASEventMutex() [2/3]

template<template< typename > class Policy = NoPolicy>
TTASEventMutex< Policy >::TTASEventMutex ( TTASEventMutex< Policy > &&  )
privatedelete

Disable copying.

◆ TTASEventMutex() [3/3]

template<template< typename > class Policy = NoPolicy>
TTASEventMutex< Policy >::TTASEventMutex ( const TTASEventMutex< Policy > &  )
privatedelete

Member Function Documentation

◆ clear_waiters()

template<template< typename > class Policy = NoPolicy>
void TTASEventMutex< Policy >::clear_waiters ( )
inlineprivate

Note that there are no threads waiting on the mutex.

◆ destroy()

template<template< typename > class Policy = NoPolicy>
void TTASEventMutex< Policy >::destroy ( )
inline

This is the real destructor.

This mutex can be created in BSS and its destructor will be called on exit(). We can't call os_event_destroy() at that stage.

◆ enter()

template<template< typename > class Policy = NoPolicy>
void TTASEventMutex< Policy >::enter ( uint32_t  max_spins,
uint32_t  max_delay,
const char *  filename,
uint32_t  line 
)
inline

Acquire the mutex.

Parameters
[in]max_spinsmax number of spins
[in]max_delaymax delay per spin
[in]filenamefrom where called
[in]linewithin filename

◆ event()

template<template< typename > class Policy = NoPolicy>
os_event_t TTASEventMutex< Policy >::event ( )
inline

The event that the mutex will wait in sync0arr.cc.

Returns
even instance

◆ exit()

template<template< typename > class Policy = NoPolicy>
void TTASEventMutex< Policy >::exit ( )
inline

Release the mutex.

◆ init()

template<template< typename > class Policy = NoPolicy>
void TTASEventMutex< Policy >::init ( latch_id_t  id,
const char *  filename,
uint32_t  line 
)
inline

Called when the mutex is "created".

Note: Not from the constructor but when the mutex is initialised.

Parameters
[in]idMutex ID
[in]filenameFile where mutex was created
[in]lineLine in filename

◆ is_free()

template<template< typename > class Policy = NoPolicy>
bool TTASEventMutex< Policy >::is_free ( uint32_t  max_spins,
uint32_t  max_delay,
uint32_t &  n_spins 
) const
inlineprivate

Spin and wait for the mutex to become free.

Parameters
[in]max_spinsmax spins
[in]max_delaymax delay per spin
[in,out]n_spinsspin start index
Returns
true if unlocked

◆ is_locked()

template<template< typename > class Policy = NoPolicy>
bool TTASEventMutex< Policy >::is_locked ( ) const
inline
Returns
true if locked by some thread

◆ is_owned()

template<template< typename > class Policy = NoPolicy>
bool TTASEventMutex< Policy >::is_owned ( ) const
inline
Returns
true if the calling thread owns the mutex.

◆ operator=() [1/2]

template<template< typename > class Policy = NoPolicy>
TTASEventMutex & TTASEventMutex< Policy >::operator= ( const TTASEventMutex< Policy > &  )
privatedelete

◆ operator=() [2/2]

template<template< typename > class Policy = NoPolicy>
TTASEventMutex & TTASEventMutex< Policy >::operator= ( TTASEventMutex< Policy > &&  )
privatedelete

◆ peek_owner()

template<template< typename > class Policy = NoPolicy>
std::thread::id TTASEventMutex< Policy >::peek_owner ( ) const
inline

If the lock is locked, returns the current owner of the lock, otherwise returns the default std::thread::id{}.

◆ policy() [1/2]

template<template< typename > class Policy = NoPolicy>
MutexPolicy & TTASEventMutex< Policy >::policy ( )
inline
Returns
non-const version of the policy

◆ policy() [2/2]

template<template< typename > class Policy = NoPolicy>
const MutexPolicy & TTASEventMutex< Policy >::policy ( ) const
inline
Returns
const version of the policy

◆ set_waiters()

template<template< typename > class Policy = NoPolicy>
void TTASEventMutex< Policy >::set_waiters ( )
inlineprivate

Note that there are threads waiting on the mutex.

◆ signal()

template<template< typename > class Policy>
void TTASEventMutex< Policy >::signal
private

Wakeup any waiting thread(s).

◆ spin_and_try_lock()

template<template< typename > class Policy = NoPolicy>
void TTASEventMutex< Policy >::spin_and_try_lock ( uint32_t  max_spins,
uint32_t  max_delay,
const char *  filename,
uint32_t  line 
)
inlineprivate

Spin while trying to acquire the mutex.

Parameters
[in]max_spinsmax number of spins
[in]max_delaymax delay per spin
[in]filenamefrom where called
[in]linewithin filename

◆ try_lock()

template<template< typename > class Policy = NoPolicy>
bool TTASEventMutex< Policy >::try_lock ( )
inline

Try and lock the mutex.

Note: POSIX returns 0 on success.

Returns
true on success

◆ wait()

template<template< typename > class Policy>
bool TTASEventMutex< Policy >::wait ( const char *  filename,
uint32_t  line,
uint32_t  spin 
)
private

Wait in the sync array.

Parameters
[in]filenamefrom where it was called
[in]lineline number in file
[in]spinretry this many times again
Returns
true if the mutex acquisition was successful.
true if the mutex acquisition was successful.

Member Data Documentation

◆ m_event

template<template< typename > class Policy = NoPolicy>
os_event_t TTASEventMutex< Policy >::m_event {}
private

Used by sync0arr.cc for the wait queue.

◆ m_owner

template<template< typename > class Policy = NoPolicy>
std::atomic<std::thread::id> TTASEventMutex< Policy >::m_owner {std::thread::id{}}
private

Set to owner's thread's id when locked, and reset to the default std::thread::id{} when unlocked.

◆ m_policy

template<template< typename > class Policy = NoPolicy>
MutexPolicy TTASEventMutex< Policy >::m_policy
private

Policy data.

◆ m_waiters

template<template< typename > class Policy = NoPolicy>
std::atomic_bool TTASEventMutex< Policy >::m_waiters {false}
private

true if there are (or may be) threads waiting in the global wait array for this mutex to be released.


The documentation for this struct was generated from the following files: