libkipr  1.0.0
Threading

Classes

struct  mutex
 A mutex, or lock. More...
 
struct  thread
 A thread, or separate process. More...
 

Typedefs

typedef void(* thread_function) ()
 thread_function is a wrapper for functions of all return types. More...
 

Functions

EXPORT_SYM mutex mutex_create ()
 
EXPORT_SYM void mutex_lock (mutex m)
 
EXPORT_SYM int mutex_trylock (mutex m)
 
EXPORT_SYM void mutex_unlock (mutex m)
 
EXPORT_SYM void mutex_destroy (mutex m)
 
EXPORT_SYM thread thread_create (thread_function func)
 
EXPORT_SYM void thread_start (thread id)
 
EXPORT_SYM void thread_wait (thread id)
 
EXPORT_SYM void thread_destroy (thread id)
 

Detailed Description

Typedef Documentation

◆ thread_function

typedef void(* thread_function) ()

thread_function is a wrapper for functions of all return types.

thread_function is defined so that any function will be accepted by thread_start by automatically casting it to a thread_function so functions with all return types, whether int, float, etc, can be threaded

Function Documentation

◆ mutex_create()

EXPORT_SYM mutex mutex_create ( )

Create a mutex.

See also
mutex

◆ mutex_destroy()

EXPORT_SYM void mutex_destroy ( mutex  m)

Destroy the mutex. This is used for cleanup after your program has finished with the mutex.

◆ mutex_lock()

EXPORT_SYM void mutex_lock ( mutex  m)

Locks the mutex. This means that only the thread that locked the mutex will run until the mutex is unlocked.

See also
mutex_unlock

◆ mutex_trylock()

EXPORT_SYM int mutex_trylock ( mutex  m)

Try to lock the mutex.

Returns
1 on success locking, 0 on failure to lock.
See also
mutex_lock

◆ mutex_unlock()

EXPORT_SYM void mutex_unlock ( mutex  m)

Unlocks the mutex. This means that other threads (if present) will run again.

See also
mutex_lock

◆ thread_create()

EXPORT_SYM thread thread_create ( thread_function  func)

Create a thread that will run the given function.

Parameters
funcThe function that the thread will run

◆ thread_destroy()

EXPORT_SYM void thread_destroy ( thread  id)

Destroy the thread. This is used for cleanup after your program has finished with the thread.

◆ thread_start()

EXPORT_SYM void thread_start ( thread  id)

Run the given thread

Parameters
idThe thread to run

◆ thread_wait()

EXPORT_SYM void thread_wait ( thread  id)

Wait until the given thread has finished running.

Parameters
idThe thread to wait for.