drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
os0thread.h File Reference
#include "univ.i"
#include <pthread.h>
Include dependency graph for os0thread.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define os0thread_h
#define OS_THREAD_MAX_N   srv_max_n_threads
#define OS_THREAD_PRIORITY_NONE   100
#define OS_THREAD_PRIORITY_BACKGROUND   1
#define OS_THREAD_PRIORITY_NORMAL   2
#define OS_THREAD_PRIORITY_ABOVE_NORMAL   3

Typedefs

typedef pthread_t os_thread_t
typedef os_thread_t os_thread_id_t
typedef void *(* os_posix_f_t) (void *)

Functions

UNIV_INTERN ibool os_thread_eq (os_thread_id_t a, os_thread_id_t b)
UNIV_INTERN ulint os_thread_pf (os_thread_id_t a)
UNIV_INTERN os_thread_t os_thread_create (os_posix_f_t start_f, void *arg, os_thread_id_t *thread_id)
UNIV_INTERN void os_thread_exit (void *exit_value)
UNIV_INTERN os_thread_id_t os_thread_get_curr_id (void)
UNIV_INTERN os_thread_t os_thread_get_curr (void)
UNIV_INTERN void os_thread_yield (void)
UNIV_INTERN void os_thread_sleep (ulint tm)
UNIV_INTERN ulint os_thread_get_priority (os_thread_t handle)
UNIV_INTERN void os_thread_set_priority (os_thread_t handle, ulint pri)
UNIV_INTERN ulint os_thread_get_last_error (void)

Detailed Description

The interface to the operating system process and thread control primitives

Created 9/8/1995 Heikki Tuuri

Definition in file os0thread.h.

Macro Definition Documentation

◆ os0thread_h

#define os0thread_h

Definition at line 29 of file os0thread.h.

◆ OS_THREAD_MAX_N

#define OS_THREAD_MAX_N   srv_max_n_threads

Definition at line 37 of file os0thread.h.

◆ OS_THREAD_PRIORITY_ABOVE_NORMAL

#define OS_THREAD_PRIORITY_ABOVE_NORMAL   3

Definition at line 44 of file os0thread.h.

◆ OS_THREAD_PRIORITY_BACKGROUND

#define OS_THREAD_PRIORITY_BACKGROUND   1

Definition at line 42 of file os0thread.h.

◆ OS_THREAD_PRIORITY_NONE

#define OS_THREAD_PRIORITY_NONE   100

Definition at line 41 of file os0thread.h.

◆ OS_THREAD_PRIORITY_NORMAL

#define OS_THREAD_PRIORITY_NORMAL   2

Definition at line 43 of file os0thread.h.

Typedef Documentation

◆ os_posix_f_t

typedef void *(* os_posix_f_t) (void *)

Definition at line 59 of file os0thread.h.

◆ os_thread_id_t

typedef os_thread_t os_thread_id_t

In Unix we use the thread handle itself as the id of the thread

Definition at line 53 of file os0thread.h.

◆ os_thread_t

typedef pthread_t os_thread_t

Definition at line 52 of file os0thread.h.

Function Documentation

◆ os_thread_create()

UNIV_INTERN os_thread_t os_thread_create ( os_posix_f_t start_f,
void * arg,
os_thread_id_t * thread_id )

Creates a new thread of execution. The execution starts from the function given. The start function takes a void* parameter and returns a ulint. NOTE: We count the number of threads in os_thread_exit(). A created thread should always use that to exit and not use return() to exit.

Returns
handle to the thread out: id of the created thread, or NULL

Creates a new thread of execution. The execution starts from the function given. The start function takes a void* parameter and returns an ulint.

Returns
handle to the thread
Parameters
argin: argument to start function
thread_idout: id of the created thread, or NULL

Definition at line 110 of file os0thread.cc.

◆ os_thread_eq()

UNIV_INTERN ibool os_thread_eq ( os_thread_id_t a,
os_thread_id_t b )

Compares two thread ids for equality.

Returns
TRUE if equal in: OS thread or thread id

Compares two thread ids for equality.

Returns
TRUE if equal
Parameters
ain: OS thread or thread id
bin: OS thread or thread id

Definition at line 46 of file os0thread.cc.

◆ os_thread_exit()

UNIV_INTERN void os_thread_exit ( void * exit_value)

Exits the current thread. in: exit value; in Windows this void* is cast as a DWORD

Exits the current thread.

Parameters
exit_valuein: exit value; in Windows this void* is cast as a DWORD

Definition at line 199 of file os0thread.cc.

◆ os_thread_get_curr()

UNIV_INTERN os_thread_t os_thread_get_curr ( void )

Returns handle to the current thread.

Returns
current thread handle

Definition at line 230 of file os0thread.cc.

◆ os_thread_get_curr_id()

UNIV_INTERN os_thread_id_t os_thread_get_curr_id ( void )

Returns the thread identifier of current thread.

Returns
current thread identifier

Returns the thread identifier of current thread. Currently the thread identifier in Unix is the thread handle itself. Note that in HP-UX pthread_t is a struct of 3 fields.

Returns
current thread identifier

Definition at line 93 of file os0thread.cc.

◆ os_thread_get_last_error()

UNIV_INTERN ulint os_thread_get_last_error ( void )

Gets the last operating system error code for the calling thread.

Returns
last error on Windows, 0 otherwise

Definition at line 348 of file os0thread.cc.

◆ os_thread_get_priority()

UNIV_INTERN ulint os_thread_get_priority ( os_thread_t handle)

Gets a thread priority.

Returns
priority in: OS handle to the thread

Gets a thread priority.

Returns
priority
Parameters
handlein: OS handle to the thread

Definition at line 316 of file os0thread.cc.

◆ os_thread_pf()

UNIV_INTERN ulint os_thread_pf ( os_thread_id_t a)

Converts an OS thread id to a ulint. It is NOT guaranteed that the ulint is unique for the thread though!

Returns
thread identifier as a number in: OS thread identifier

Converts an OS thread id to a ulint. It is NOT guaranteed that the ulint is unique for the thread though!

Returns
thread identifier as a number
Parameters
ain: OS thread identifier

Definition at line 72 of file os0thread.cc.

◆ os_thread_set_priority()

UNIV_INTERN void os_thread_set_priority ( os_thread_t handle,
ulint pri )

Sets a thread priority. in: priority: one of OS_PRIORITY_...

Sets a thread priority.

Parameters
handlein: OS handle to the thread
priin: priority

Definition at line 286 of file os0thread.cc.

◆ os_thread_sleep()

UNIV_INTERN void os_thread_sleep ( ulint tm)

The thread sleeps at least the time given in microseconds. in: time in microseconds

The thread sleeps at least the time given in microseconds.

Parameters
tmin: time in microseconds

Definition at line 265 of file os0thread.cc.

◆ os_thread_yield()

UNIV_INTERN void os_thread_yield ( void )

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

Definition at line 244 of file os0thread.cc.