mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-02-18 19:03:16 +00:00
- Removed custom `TickType` - Removed TactilityC functionality that is now covered by TactilityFreeRtos
29 lines
693 B
C++
29 lines
693 B
C++
#include <Tactility/Mutex.h>
|
|
#include <Tactility/RecursiveMutex.h>
|
|
#include <Tactility/file/File.h>
|
|
#include <tt_lock.h>
|
|
#include <tt_lock_private.h>
|
|
|
|
#define HANDLE_AS_LOCK(handle) (static_cast<LockHolder*>(handle)->lock)
|
|
|
|
extern "C" {
|
|
|
|
LockHandle tt_lock_alloc_for_path(const char* path) {
|
|
const auto lock = tt::file::getLock(path);
|
|
return new LockHolder(lock);
|
|
}
|
|
|
|
bool tt_lock_acquire(LockHandle handle, TickType_t timeout) {
|
|
return HANDLE_AS_LOCK(handle)->lock(timeout);
|
|
}
|
|
|
|
void tt_lock_release(LockHandle handle) {
|
|
HANDLE_AS_LOCK(handle)->unlock();
|
|
}
|
|
|
|
void tt_lock_free(LockHandle handle) {
|
|
const auto holder = static_cast<LockHolder*>(handle);
|
|
delete holder;
|
|
}
|
|
|
|
} |