The Sequence Toolkit
www.sequence-toolkit.com
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
Macros | Functions
stk_sync_api.h File Reference
#include "stk_sync.h"
#include "stk_common.h"
#include <pthread.h>
Include dependency graph for stk_sync_api.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define stk_atomic_increment(_var)   stk_fetch_and_add(_var,1)
 
#define stk_atomic_decrement(_var)   stk_fetch_and_add(_var,-1)
 
#define stk_atomic_read(_var)   stk_fetch_and_add(_var,0)
 

Functions

stk_ret stk_mutex_init (stk_mutex_t **mt_ptr)
 
stk_ret stk_mutex_destroy (stk_mutex_t *mutex)
 
stk_ret stk_mutex_lock (stk_mutex_t *mutex)
 
stk_ret stk_mutex_trylock (stk_mutex_t *mutex)
 
stk_ret stk_mutex_unlock (stk_mutex_t *mutex)
 
int stk_fetch_and_add (int *variable, int value)
 

Detailed Description

The stk_sync API's provide an atomic and mutex implementation used by STK modules

Macro Definition Documentation

#define stk_atomic_decrement (   _var)    stk_fetch_and_add(_var,-1)

Atomic decrement of an int.

Returns
The old value
#define stk_atomic_increment (   _var)    stk_fetch_and_add(_var,1)

Atomic increment of an int.

Returns
The old value
#define stk_atomic_read (   _var)    stk_fetch_and_add(_var,0)

Atomic read of an int.

Returns
The old value

Function Documentation

int stk_fetch_and_add ( int *  variable,
int  value 
)

Atomic add of an int.

Returns
The old value
stk_ret stk_mutex_destroy ( stk_mutex_t mutex)

Destroy a mutex

Returns
STK_SUCCESS if destroyed successfully
stk_ret stk_mutex_init ( stk_mutex_t **  mt_ptr)

Create a non-recursive mutex

Returns
STK_SUCCESS if created
stk_ret stk_mutex_lock ( stk_mutex_t mutex)

Lock a mutex

Returns
STK_SUCCESS if locked successfully
stk_ret stk_mutex_trylock ( stk_mutex_t mutex)

TryLock a mutex

Returns
STK_SUCCESS if locked successfully
stk_ret stk_mutex_unlock ( stk_mutex_t mutex)

Unlock a mutex

Returns
STK_SUCCESS if unlocked successfully