BSB Developer Docs
Loading...
Searching...
No Matches
api_lock.h
1
#pragma once
2
#include <furi/furi.h>
3
4
/*
5
Testing 10000 api calls
6
7
No lock
8
Time diff: 445269.218750 us
9
Time per call: 44.526920 us
10
11
furi_thread_flags
12
Time diff: 430279.875000 us // lol wtf? smaller than no lock?
13
Time per call: 43.027988 us // I tested it many times, it's always smaller
14
15
FuriEventFlag
16
Time diff: 831523.625000 us
17
Time per call: 83.152359 us
18
19
FuriSemaphore
20
Time diff: 999807.125000 us
21
Time per call: 99.980713 us
22
23
FuriMutex
24
Time diff: 1071417.500000 us
25
Time per call: 107.141747 us
26
*/
27
28
typedef
FuriEventFlag* FuriApiLock;
29
30
#define API_LOCK_EVENT (1U << 0)
31
32
#define api_lock_alloc_locked() furi_event_flag_alloc()
33
34
#define api_lock_wait_unlock(_lock) \
35
furi_event_flag_wait(_lock, API_LOCK_EVENT, FuriFlagWaitAny, FuriWaitForever)
36
37
#define api_lock_free(_lock) furi_event_flag_free(_lock)
38
39
#define api_lock_unlock(_lock) furi_event_flag_set(_lock, API_LOCK_EVENT)
40
41
#define api_lock_wait_unlock_and_free(_lock) \
42
api_lock_wait_unlock(_lock); \
43
api_lock_free(_lock);
44
45
#define api_lock_is_locked(_lock) (!(furi_event_flag_get(_lock) & API_LOCK_EVENT))
46
47
#define api_lock_relock(_lock) furi_event_flag_clear(_lock, API_LOCK_EVENT)
lib
toolbox
api_lock.h
Generated by
1.12.0