MySQL  8.0.21
Source Code Documentation
os0thread.h File Reference

The interface to the operating system process and thread control primitives. More...

#include <atomic>
#include <future>
#include <thread>

Go to the source code of this file.

Classes

class  IB_thread
 

Macros

#define os_thread_handle()   ((uint64_t)(os_thread_get_curr_id()))
 Return the thread handle. More...
 
#define os_thread_eq(lhs, rhs)   ((lhs) == (rhs))
 Compares two thread ids for equality. More...
 
#define os_thread_yield()
 Advises the OS to give up remainder of the thread's time slice. More...
 
#define os_thread_sleep(usecs)
 The thread sleeps at least the time given in microseconds. More...
 

Typedefs

using os_thread_id_t = std::thread::native_handle_type
 Operating system thread native handle. More...
 

Functions

os_thread_id_t os_thread_get_curr_id ()
 Returns the thread identifier of current thread. More...
 
bool os_thread_set_priority (int priority)
 Set priority for current thread. More...
 
void os_thread_set_priority (int priority, const char *thread_name)
 Set priority for current thread. More...
 

Detailed Description

The interface to the operating system process and thread control primitives.

Created 9/8/1995 Heikki Tuuri

Macro Definition Documentation

◆ os_thread_eq

#define os_thread_eq (   lhs,
  rhs 
)    ((lhs) == (rhs))

Compares two thread ids for equality.

Parameters
[in]lhsOS thread or thread id
[in]rhsOS thread or thread id return true if equal

◆ os_thread_handle

#define os_thread_handle ( )    ((uint64_t)(os_thread_get_curr_id()))

Return the thread handle.

The purpose of this function is to cast the native handle to an integer type for consistency

Returns
the current thread ID cast to an uint64_t

◆ os_thread_sleep

#define os_thread_sleep (   usecs)
Value:
do { \
std::this_thread::sleep_for(std::chrono::microseconds(usecs)); \
} while (false)

The thread sleeps at least the time given in microseconds.

Parameters
[in]usecstime in microseconds

◆ os_thread_yield

#define os_thread_yield ( )
Value:
do { \
std::this_thread::yield(); \
} while (false)

Advises the OS to give up remainder of the thread's time slice.

Typedef Documentation

◆ os_thread_id_t

using os_thread_id_t = std::thread::native_handle_type

Operating system thread native handle.

Function Documentation

◆ os_thread_get_curr_id()

os_thread_id_t os_thread_get_curr_id ( )

Returns the thread identifier of current thread.

Currently the thread identifier in Unix is the thread handle itself.

Returns
current thread native handle

◆ os_thread_set_priority() [1/2]

bool os_thread_set_priority ( int  priority)

Set priority for current thread.

Parameters
[in]prioritypriority intended to set
Return values
trueset as intended
falsegot different priority after attempt to set

◆ os_thread_set_priority() [2/2]

void os_thread_set_priority ( int  priority,
const char *  thread_name 
)

Set priority for current thread.

Parameters
[in]prioritypriority intended to set
[in]thread_namename of thread, used for log message