blob: 087598cdc9bd5018ba2ab59c4ea72c82fa446448 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
#pragma once
#include <mutex>
// Do we want to activate full lane tracking feature?
#define HAVE_LANE_TRACKING() 1
#if HAVE_LANE_TRACKING()
class Lane;
struct lua_State;
// The chain is ended by '(Lane*)(-1)', not nullptr:
// 'trackingFirst -> ... -> ... -> (-1)'
#define TRACKING_END ((Lane*) (-1))
class LaneTracker
{
private:
mutable std::mutex trackingMutex;
Lane* volatile trackingFirst{ nullptr }; // will change to TRACKING_END if we want to activate tracking
public:
void tracking_add(Lane* lane_);
[[nodiscard]] bool tracking_remove(Lane* lane_);
[[nodiscard]] int pushThreadsTable(lua_State* L_) const;
void activate() {
trackingFirst = TRACKING_END;
}
[[nodiscard]] bool isActive() const {
return trackingFirst != nullptr;
}
};
#endif // HAVE_LANE_TRACKING()
|