facil.io

#./fio-stl/002 threads.h

32 public symbols.

#Macros

#FIO_THREAD_MUTEX_INIT

c
#define FIO_THREAD_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER

Used this macro for static initialization.

Symbol type: macro

#FIO_MEMCPY_THREADS

c
#define FIO_MEMCPY_THREADS 8

Symbol type: macro

#Types

#fio_thread_t

c
typedef pthread_t fio_thread_t

Symbol type: type

#fio_thread_pid_t

c
typedef pid_t fio_thread_pid_t

Symbol type: type

#fio_thread_mutex_t

c
typedef pthread_mutex_t fio_thread_mutex_t

Symbol type: type

#fio_thread_cond_t

c
typedef pthread_cond_t fio_thread_cond_t

Symbol type: type

#fio_thread_priority_e

c
typedef enum {
FIO_THREAD_PRIORITY_ERROR = -1,
FIO_THREAD_PRIORITY_LOWEST = 0,
FIO_THREAD_PRIORITY_LOW,
FIO_THREAD_PRIORITY_NORMAL,
FIO_THREAD_PRIORITY_HIGH,
FIO_THREAD_PRIORITY_HIGHEST,
} fio_thread_priority_e

Possible thread priority values.

Symbol type: type

#Functions

#fio_thread_fork

c
inline fio_thread_pid_t fio_thread_fork(void)

Should behave the same as the POSIX system call fork.

Symbol type: function

#fio_thread_getpid

c
inline fio_thread_pid_t fio_thread_getpid(void)

Should behave the same as the POSIX system call getpid.

Symbol type: function

#fio_thread_kill

c
inline int fio_thread_kill(fio_thread_pid_t pid, int sig)

Should behave the same as the POSIX system call kill.

Symbol type: function

#fio_thread_waitpid

c
inline int fio_thread_waitpid(fio_thread_pid_t pid, int *stat_loc, int options)

Should behave the same as the POSIX system call waitpid.

Symbol type: function

#fio_thread_create

c
inline int fio_thread_create(fio_thread_t *t, void *(*fn)(void *), void *arg)

Starts a new thread, returns 0 on success and -1 on failure.

Symbol type: function

#fio_thread_join

c
inline int fio_thread_join(fio_thread_t *t)

Waits for the thread to finish.

Symbol type: function

#fio_thread_detach

c
inline int fio_thread_detach(fio_thread_t *t)

Detaches the thread, so thread resources are freed automatically.

Symbol type: function

#fio_thread_exit

c
inline void fio_thread_exit(void)

Ends the current running thread.

Symbol type: function

#fio_thread_equal

c
inline int fio_thread_equal(fio_thread_t *a, fio_thread_t *b)

Symbol type: function

#fio_thread_current

c
inline fio_thread_t fio_thread_current(void)

Returns the current thread.

Symbol type: function

#fio_thread_nid

c
inline uintptr_t fio_thread_nid(void)

Returns a process-local numeral ID for the current thread.

The value is stable for the thread's lifetime and unique among live threads. It may be reused after the thread exits.

Symbol type: function

#fio_thread_yield

c
inline void fio_thread_yield(void)

Yields thread execution.

Symbol type: function

#fio_thread_priority

c
FIO_SFUNC fio_thread_priority_e fio_thread_priority(void)

Returns a thread's priority level.

Symbol type: function

#fio_thread_priority_set

c
FIO_SFUNC int fio_thread_priority_set(fio_thread_priority_e)

Sets a thread's priority level.

Symbol type: function

#fio_thread_mutex_init

c
inline int fio_thread_mutex_init(fio_thread_mutex_t *m)

Initializes a simple Mutex.

Or use the static initialization value: FIO_THREAD_MUTEX_INIT

Symbol type: function

#fio_thread_mutex_lock

c
inline int fio_thread_mutex_lock(fio_thread_mutex_t *m)

Locks a simple Mutex, returning -1 on error.

Symbol type: function

#fio_thread_mutex_trylock

c
inline int fio_thread_mutex_trylock(fio_thread_mutex_t *m)

Attempts to lock a simple Mutex, returning zero on success.

Symbol type: function

#fio_thread_mutex_unlock

c
inline int fio_thread_mutex_unlock(fio_thread_mutex_t *m)

Unlocks a simple Mutex, returning zero on success or -1 on error.

Symbol type: function

#fio_thread_mutex_destroy

c
inline void fio_thread_mutex_destroy(fio_thread_mutex_t *m)

Destroys the simple Mutex (cleanup).

Symbol type: function

#fio_thread_cond_init

c
inline int fio_thread_cond_init(fio_thread_cond_t *c)

Initializes a simple conditional variable.

Symbol type: function

#fio_thread_cond_wait

c
inline int fio_thread_cond_wait(fio_thread_cond_t *c, fio_thread_mutex_t *m)

Waits on a conditional variable (MUST be previously locked).

Symbol type: function

#fio_thread_cond_timedwait

c
inline int fio_thread_cond_timedwait(fio_thread_cond_t *c, fio_thread_mutex_t *m, size_t milliseconds)

Waits on a conditional variable (MUST be previously locked).

Symbol type: function

#fio_thread_cond_signal

c
inline int fio_thread_cond_signal(fio_thread_cond_t *c)

Signals a simple conditional variable.

Symbol type: function

#fio_thread_cond_destroy

c
inline void fio_thread_cond_destroy(fio_thread_cond_t *c)

Destroys a simple conditional variable.

Symbol type: function

#fio_thread_memcpy

c
FIO_SFUNC size_t fio_thread_memcpy(void *restrict dest, const void *restrict src, size_t bytes)

Multi-threaded memcpy using up to FIO_MEMCPY_THREADS threads

Symbol type: function