MapleMutexCreate
create a mutex
Calling Sequence
Parameters
Description
Examples
MapleMutexCreate( kv, options );
kv
-
kernel handle of type MKernelVector
options
an expression sequence of options (ALGEB)
MapleMutexCreate creates a mutex that can be used to implement critical sections in external call code. It returns an mutex identifier that is passed into MapleMutexLock and MapleMutexUnlock.
There are currently no options supported by the MapleMutexCreate, thus a Maple null should be passed for the options argument. A Maple null can be obtained by calling ToMapleNULL.
The mutex identifier returned by MapleMutexCreate is compatible with the functions in the Threads[Mutex] package. Thus mutexes created by MapleMutexCreate can be returned to Maple and used by Threads[Mutex][Lock] and Threads[Mutex][Unlock].
When a mutex is no longer needed it should be released by passing it into MapleMutexDestroy.
#include "maplec.h"
ALGEB M_DECL Function( MKernelVector kv, ALGEB args )
{
ALGEB mutex, ret;
mutex = MapleMutexCreate( kv, ToMapleNULL(kv) );
ret = DoParallelWork( kv, mutex, args );
MapleMutexDestroy( kv, mutex );
return ret;
}
See Also
CustomWrapper
define_external
MapleMutexDestroy
MapleMutexLock
MapleMutexUnlock
OpenMaple
OpenMaple/C/API
OpenMaple/C/Examples
OpenMaple/C/MutexDestroy
OpenMaple/C/MutexLock
OpenMaple/C/MutexUnlock
Threads[Mutex]
Download Help Document