2011-02-25 13:31:20 +01:00
|
|
|
#ifndef _DDEKIT_LOCK_H
|
|
|
|
#define _DDEKIT_LOCK_H
|
|
|
|
|
|
|
|
#include <ddekit/ddekit.h>
|
|
|
|
|
|
|
|
struct ddekit_lock;
|
|
|
|
typedef struct ddekit_lock *ddekit_lock_t;
|
|
|
|
|
|
|
|
/* Initialize a DDEKit unlocked lock. */
|
|
|
|
#define ddekit_lock_init ddekit_lock_init_unlocked
|
|
|
|
|
|
|
|
/* Initialize a DDEKit unlocked lock. */
|
2012-03-24 16:16:34 +01:00
|
|
|
void ddekit_lock_init_unlocked(ddekit_lock_t *mtx);
|
2011-02-25 13:31:20 +01:00
|
|
|
|
|
|
|
/* Initialize a DDEKit locked lock. */
|
2012-03-24 16:16:34 +01:00
|
|
|
void ddekit_lock_init_locked(ddekit_lock_t *mtx);
|
2011-02-25 13:31:20 +01:00
|
|
|
|
|
|
|
/* Uninitialize a DDEKit lock. */
|
2012-03-24 16:16:34 +01:00
|
|
|
void ddekit_lock_deinit(ddekit_lock_t *mtx);
|
2011-02-25 13:31:20 +01:00
|
|
|
|
|
|
|
/* Acquire a lock. */
|
2012-03-24 16:16:34 +01:00
|
|
|
void ddekit_lock_lock(ddekit_lock_t *mtx);
|
2011-02-25 13:31:20 +01:00
|
|
|
|
|
|
|
/* Acquire a lock, non-blocking. */
|
2012-03-24 16:16:34 +01:00
|
|
|
int ddekit_lock_try_lock(ddekit_lock_t *mtx);
|
2011-02-25 13:31:20 +01:00
|
|
|
|
|
|
|
/* Unlock function. */
|
2012-03-24 16:16:34 +01:00
|
|
|
void ddekit_lock_unlock(ddekit_lock_t *mtx);
|
2011-02-25 13:31:20 +01:00
|
|
|
|
|
|
|
/* Get lock owner. */
|
2012-03-24 16:16:34 +01:00
|
|
|
int ddekit_lock_owner(ddekit_lock_t *mtx);
|
2011-02-25 13:31:20 +01:00
|
|
|
|
|
|
|
#endif
|