Table Of Contents

Previous topic

Path Functions

Next topic

Strings

Threads

A set of macros to access multi-threaded functionality. The Speect Engine itself is not multi-threaded, but it does need access to mutex locks to be thread safe, and thread id’s for logging purposes. Different multi-threaded implementations are supported by implementing the macros.

Summary

S_DECLARE_MUTEX Declare a s_mutex.
S_DECLARE_MUTEX_STATIC Declare a static s_mutex.
s_mutex_init Initialize a mutex.
s_mutex_destroy Destroy a mutex.
s_mutex_lock Lock a mutex.
s_mutex_unlock Unlock a mutex.
s_thread_id Get the calling thread id.

Definitions

typedef s_mutex_t s_mutex

Definition of a opaque mutex structure.

Declarations

macro S_DECLARE_MUTEX(NAME)

Declare a s_mutex.

Declare a s_mutex with the given name, based on the threads implementation.

Parameters:
  • NAME

    The name of the static s_mutex.

macro S_DECLARE_MUTEX_STATIC(NAME)

Declare a static s_mutex.

Declare a static s_mutex with the given name, based on the threads implementation.

Parameters:
  • NAME

    The name of the static s_mutex.

Initialize/Destroy

macro s_mutex_init(mutex)

Initialize a mutex.

Initializes the given s_mutex mutex using the default mutex attributes.

Parameters:
  • mutex

    s_mutex mutex pointer to initialize.

macro s_mutex_destroy(mutex)

Destroy a mutex.

Destroys the given s_mutex mutex.

Parameters:
  • mutex

    s_mutex mutex pointer to destroy.

Lock/Unlock

macro s_mutex_lock(mutex)

Lock a mutex.

Locks the given s_mutex mutex so that it can only be accessed by one thread.

Parameters:
  • mutex

    s_mutex mutex pointer to lock.

macro s_mutex_unlock(mutex)

Unlock a mutex.

Unlocks the given s_mutex mutex that has previously been locked by s_mutex_lock, so that it is accessible to all threads.

Parameters:
  • mutex

    s_mutex mutex pointer to unlock.

Miscellaneous

macro s_thread_id

Get the calling thread id.

Return:The calling thread id as an unsigned long.