AWS IoT Device SDK C: Platform
Platform portability layer
Return to main page ↑
IotMutex_Create

Create a new mutex.

bool IotMutex_Create( IotMutex_t * pNewMutex, bool recursive );

This function creates a new, unlocked mutex. It must be called on an uninitialized IotMutex_t. This function must not be called on an already-initialized IotMutex_t.

Parameters
[in]pNewMutexPointer to the memory that will hold the new mutex.
[in]recursiveSet to true to create a recursive mutex, i.e. a mutex that may be locked multiple times by the same thread. If the system does not support recursive mutexes, this function should do nothing and return false.
Returns
true if mutex creation succeeds; false otherwise.
See also
IotMutex_Destroy

Example

IotMutex_t mutex;
// Create non-recursive mutex.
if( IotMutex_Create( &mutex, false ) == true )
{
// Lock and unlock the mutex...
// Destroy the mutex when it's no longer needed.
IotMutex_Destroy( &mutex );
}