Ken Van Hoeylandt 415096c3b2
Update docs and fix bugs (#149)
Improved the docs for the 3 main Tactility projects. I also fixed some inaccuracies and bugs in certain APIs as I went through the code.
2025-01-07 20:45:23 +01:00

31 lines
764 B
C++

#include "tt_mutex.h"
#include "Mutex.h"
extern "C" {
#define HANDLE_AS_MUTEX(handle) ((tt::Mutex*)(handle))
MutexHandle tt_mutex_alloc(enum TtMutexType type) {
switch (type) {
case TtMutexType::MUTEX_TYPE_NORMAL:
return new tt::Mutex(tt::Mutex::TypeNormal);
case TtMutexType::MUTEX_TYPE_RECURSIVE:
return new tt::Mutex(tt::Mutex::TypeRecursive);
default:
tt_crash("Type not supported");
}
}
void tt_mutex_free(MutexHandle handle) {
delete HANDLE_AS_MUTEX(handle);
}
bool tt_mutex_lock(MutexHandle handle, TickType_t timeout) {
return HANDLE_AS_MUTEX(handle)->lock((TickType_t)timeout);
}
bool tt_mutex_unlock(MutexHandle handle) {
return HANDLE_AS_MUTEX(handle)->unlock();
}
}