framework/c/inc/le_mutex.h File Reference

Go to the source code of this file.

Defines

#define LE_MUTEX_DECLARE_REF(refName)

Typedefs

typedef struct le_mutex * le_mutex_Ref_t

Functions

le_mutex_Ref_t le_mutex_CreateRecursive (const char *nameStr)
le_mutex_Ref_t le_mutex_CreateNonRecursive (const char *nameStr)
le_mutex_Ref_t le_mutex_CreateTraceableRecursive (const char *nameStr)
le_mutex_Ref_t le_mutex_CreateTraceableNonRecursive (const char *nameStr)
void le_mutex_Delete (le_mutex_Ref_t mutexRef)
void le_mutex_Lock (le_mutex_Ref_t mutexRef)
le_result_t le_mutex_TryLock (le_mutex_Ref_t mutexRef)
void le_mutex_Unlock (le_mutex_Ref_t mutexRef)

Detailed Description

Legato Mutex API include file.

Copyright (C) Sierra Wireless, Inc. 2014. All rights reserved. Use of this work is subject to license.


Define Documentation

#define LE_MUTEX_DECLARE_REF (   refName)
Value:
static le_mutex_Ref_t refName; \
    static inline void Lock(void) { le_mutex_Lock(refName); } \
    static inline void Unlock(void) { le_mutex_Unlock(refName); }

Declare a static mutex reference variable and accessor functions.

This is handy when you need a single, file-scope mutex for use inside your module to protect other file-scope data structures from multi-threaded race conditions.

Adding the line

 LE_MUTEX_DECLARE_REF(MyMutexRef);

near the top of your file will create a file-scope variable called "MyMutexRef" of type le_mutex_Ref_t and functions called "Lock" and "Unlock" that access that variable.

See Tip for more information.

Parameters:
refNameName of the mutex reference variable.
Returns:
Nothing.

Typedef Documentation

typedef struct le_mutex* le_mutex_Ref_t

Reference to a Mutex object.


Function Documentation

le_mutex_Ref_t le_mutex_CreateNonRecursive ( const char *  nameStr)

Create a Normal, Non-Recursive mutex.

Returns:
Returns a reference to the mutex.
Note:
Terminates the process on failure, no need to check the return value for errors.
Parameters:
[in]nameStrName of the mutex
le_mutex_Ref_t le_mutex_CreateRecursive ( const char *  nameStr)

Create a Normal, Recursive mutex.

Returns:
Returns a reference to the mutex.
Note:
Terminates the process on failure, no need to check the return value for errors.
Parameters:
[in]nameStrName of the mutex

Create a Traceable, Non-Recursive mutex.

Returns:
Returns a reference to the mutex.
Note:
Terminates the process on failure, no need to check the return value for errors.
Parameters:
[in]nameStrName of the mutex

Create a Traceable, Recursive mutex.

Returns:
Returns a reference to the mutex.
Note:
Terminates the process on failure, no need to check the return value for errors.
Parameters:
[in]nameStrName of the mutex
void le_mutex_Delete ( le_mutex_Ref_t  mutexRef)

Delete a mutex.

Returns:
Nothing.
Parameters:
[in]mutexRefMutex reference
void le_mutex_Lock ( le_mutex_Ref_t  mutexRef)

Lock a mutex.

Returns:
Nothing.
Parameters:
[in]mutexRefMutex reference

Try a lock on a mutex.

Locks a mutex, if no other thread holds it. Otherwise, returns without locking.

Returns:
  • LE_OK if mutex was locked.
  • LE_WOULD_BLOCK if mutex was already held by someone else.
Parameters:
[in]mutexRefMutex reference
void le_mutex_Unlock ( le_mutex_Ref_t  mutexRef)

Unlock a mutex.

Returns:
Nothing.
Parameters:
[in]mutexRefMutex reference
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines