aboutsummaryrefslogtreecommitdiff
path: root/src/tracker.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/tracker.h')
-rw-r--r--src/tracker.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/tracker.h b/src/tracker.h
new file mode 100644
index 0000000..087598c
--- /dev/null
+++ b/src/tracker.h
@@ -0,0 +1,35 @@
1#pragma once
2
3#include <mutex>
4
5// Do we want to activate full lane tracking feature?
6#define HAVE_LANE_TRACKING() 1
7
8#if HAVE_LANE_TRACKING()
9
10class Lane;
11struct lua_State;
12
13// The chain is ended by '(Lane*)(-1)', not nullptr:
14// 'trackingFirst -> ... -> ... -> (-1)'
15#define TRACKING_END ((Lane*) (-1))
16
17class LaneTracker
18{
19 private:
20 mutable std::mutex trackingMutex;
21 Lane* volatile trackingFirst{ nullptr }; // will change to TRACKING_END if we want to activate tracking
22
23 public:
24 void tracking_add(Lane* lane_);
25 [[nodiscard]] bool tracking_remove(Lane* lane_);
26 [[nodiscard]] int pushThreadsTable(lua_State* L_) const;
27 void activate() {
28 trackingFirst = TRACKING_END;
29 }
30 [[nodiscard]] bool isActive() const {
31 return trackingFirst != nullptr;
32 }
33};
34
35#endif // HAVE_LANE_TRACKING()