MapleMutexCreate - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


MapleMutexCreate

create a mutex

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

MapleMutexCreate( kv, options );

Parameters

kv

-

kernel handle of type MKernelVector

options

-

an expression sequence of options (ALGEB)

Description

• 

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.

Examples

#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]