futriix-old/src/fastlock.h
2019-02-16 14:25:14 -05:00

42 lines
613 B
C

#pragma once
#ifdef __cplusplus
extern "C" {
#endif
/* Begin C API */
struct fastlock;
void fastlock_init(struct fastlock *lock);
void fastlock_lock(struct fastlock *lock);
void fastlock_unlock(struct fastlock *lock);
void fastlock_free(struct fastlock *lock);
/* End C API */
#ifdef __cplusplus
}
#endif
struct fastlock
{
volatile int m_lock;
volatile int m_pidOwner;
volatile int m_depth;
#ifdef __cplusplus
fastlock()
{
fastlock_init(this);
}
void lock()
{
fastlock_lock(this);
}
void unlock()
{
fastlock_unlock(this);
}
#endif
};