futriix/src/fastlock.h

42 lines
613 B
C
Raw Normal View History

2019-02-10 20:24:11 -05:00
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
2019-02-10 22:00:19 -05:00
/* Begin C API */
struct fastlock;
2019-02-10 20:24:11 -05:00
void fastlock_init(struct fastlock *lock);
void fastlock_lock(struct fastlock *lock);
void fastlock_unlock(struct fastlock *lock);
void fastlock_free(struct fastlock *lock);
2019-02-10 22:00:19 -05:00
/* End C API */
2019-02-10 20:24:11 -05:00
#ifdef __cplusplus
}
2019-02-10 22:00:19 -05:00
#endif
struct fastlock
{
volatile int m_lock;
2019-02-16 14:25:14 -05:00
volatile int m_pidOwner;
volatile int m_depth;
2019-02-10 22:00:19 -05:00
#ifdef __cplusplus
fastlock()
{
fastlock_init(this);
}
2019-02-10 22:00:19 -05:00
void lock()
{
fastlock_lock(this);
}
void unlock()
{
fastlock_unlock(this);
}
#endif
};