HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
dead_lock_detector.hpp
1// Copyright Take Vos 2021.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5#pragma once
6
7#include "assert.hpp"
8#include "architecture.hpp"
9#include <vector>
10#include <algorithm>
11#include <compare>
12
13
14namespace tt {
15namespace detail {
16
18 void *before;
19 void *after;
20
21 friend bool operator==(dead_lock_detector_pair const &lhs, dead_lock_detector_pair const &rhs) noexcept = default;
22 friend std::strong_ordering
23 operator<=>(dead_lock_detector_pair const &lhs, dead_lock_detector_pair const &rhs) noexcept = default;
24};
25
26}
27
29public:
35 static void *lock(void *object) noexcept;
36
41 static bool unlock(void *object) noexcept;
42
49 static void remove_object(void *object) noexcept;
50
54 static void clear_stack() noexcept;
55
59 static void clear_graph() noexcept;
60
61private:
62 thread_local inline static std::vector<void *> stack;
63
69 inline static std::vector<detail::dead_lock_detector_pair> lock_graph;
70
71 [[nodiscard]] static void *check_graph(void *object) noexcept;
72};
73
74}
STL namespace.
Definition dead_lock_detector.hpp:17
Definition dead_lock_detector.hpp:28
static void clear_graph() noexcept
Clear the graph.
static void * lock(void *object) noexcept
Lock an object on this thread.
static void clear_stack() noexcept
Clear the stack.
static void remove_object(void *object) noexcept
Remove the object from the detection.
static bool unlock(void *object) noexcept
Unlock an object on this thread.
A static sized stack.
Definition stack.hpp:23