src/
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
3 / 3
100.0%
Branches:
2 / 2
100.0%
Functions:
1 / 1
100.0%

LogLockPolicy.h
Line Branch Exec Source
1 #ifndef LOG_LOCK_POLICY_H
2 #define LOG_LOCK_POLICY_H
3 #include <stdint.h>
4
5 // When a log call stops waiting for the log lock (src/LogLock.cpp). Kept free
6 // of FreeRTOS so it can be unit tested on the PC (pio test -e native).
7
8 // What the task holding the log lock is doing.
9 enum class LogHolder {
10 unknown, // Just took the lock and hasn't recorded itself yet.
11 running, // Running on a core, so it lets go within a line.
12 preemptedHere, // Waiting for this core, so blocking lets it finish.
13 preemptedElsewhere // Preempted on another core (the radio task during a
14 // whole transmission), so waiting gets nowhere.
15 };
16 // Whether to keep waiting after waitedMs. Never past maxMs.
17 15 inline bool keepWaitingForLogLock(LogHolder holder, uint32_t waitedMs, uint32_t maxMs) {
18
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 8 times.
15 if(waitedMs >= maxMs) return false;
19 8 return holder != LogHolder::preemptedElsewhere;
20 }
21 #endif
22