Mutexes
+ Collaboration diagram for Mutexes:

Functions

long systhread_mutex_new (t_systhread_mutex *pmutex, long flags)
 Create a new mutex, which can be used to place thread locks around critical code.
long systhread_mutex_free (t_systhread_mutex pmutex)
 Free a mutex created with systhread_mutex_new().
long systhread_mutex_lock (t_systhread_mutex pmutex)
 Enter block of locked code code until a systhread_mutex_unlock() is reached.
long systhread_mutex_unlock (t_systhread_mutex pmutex)
 Exit a block of code locked with systhread_mutex_lock().
long systhread_mutex_trylock (t_systhread_mutex pmutex)
 Try to enter block of locked code code until a systhread_mutex_unlock() is reached.
long systhread_mutex_newlock (t_systhread_mutex *pmutex, long flags)
 Convenience utility that combines systhread_mutex_new() and systhread_mutex_lock().

Detailed Description

See also:
Critical Regions

Function Documentation

long systhread_mutex_free ( t_systhread_mutex  pmutex)

Free a mutex created with systhread_mutex_new().

Parameters:
pmutexThe mutex instance pointer.
Returns:
A Max error code as defined in e_max_errorcodes.
long systhread_mutex_lock ( t_systhread_mutex  pmutex)

Enter block of locked code code until a systhread_mutex_unlock() is reached.

It is important to keep the code in this block as small as possible.

Parameters:
pmutexThe mutex instance pointer.
Returns:
A Max error code as defined in e_max_errorcodes.
See also:
systhread_mutex_trylock()
long systhread_mutex_new ( t_systhread_mutex pmutex,
long  flags 
)

Create a new mutex, which can be used to place thread locks around critical code.

The mutex should be freed with systhread_mutex_free().

Parameters:
pmutexThe address of a variable to store the mutex pointer.
flagsFlags to determine the behaviour of the mutex, as defined in e_max_systhread_mutex_flags.
Returns:
A Max error code as defined in e_max_errorcodes.
Remarks:
One reason to use systhread_mutex_new() instead of Critical Regions is to create non-recursive locks, which are lighter-weight than recursive locks.
long systhread_mutex_newlock ( t_systhread_mutex pmutex,
long  flags 
)

Convenience utility that combines systhread_mutex_new() and systhread_mutex_lock().

Parameters:
pmutexThe address of a variable to store the mutex pointer.
flagsFlags to determine the behaviour of the mutex, as defined in e_max_systhread_mutex_flags.
Returns:
A Max error code as defined in e_max_errorcodes.
long systhread_mutex_trylock ( t_systhread_mutex  pmutex)

Try to enter block of locked code code until a systhread_mutex_unlock() is reached.

If the lock cannot be entered, this function will return non-zero.

Parameters:
pmutexThe mutex instance pointer.
Returns:
Returns non-zero if there was a problem entering.
See also:
systhread_mutex_lock()
long systhread_mutex_unlock ( t_systhread_mutex  pmutex)

Exit a block of code locked with systhread_mutex_lock().

Parameters:
pmutexThe mutex instance pointer.
Returns:
A Max error code as defined in e_max_errorcodes.