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
13namespace hi::inline v1 {
14namespace detail {
15
17 void *before;
18 void *after;
19
20 friend bool operator==(dead_lock_detector_pair const &lhs, dead_lock_detector_pair const &rhs) noexcept = default;
21 friend std::strong_ordering
22 operator<=>(dead_lock_detector_pair const &lhs, dead_lock_detector_pair const &rhs) noexcept = default;
23};
24
25} // namespace detail
26
36public:
42 static void *lock(void *object) noexcept;
43
48 static bool unlock(void *object) noexcept;
49
56 static void remove_object(void *object) noexcept;
57
61 static void clear_stack() noexcept;
62
66 static void clear_graph() noexcept;
67
68private:
69 thread_local inline static std::vector<void *> stack;
70
76 inline static std::vector<detail::dead_lock_detector_pair> lock_graph;
77
78 [[nodiscard]] static void *check_graph(void *object) noexcept;
79};
80
81} // namespace hi::inline v1
Functions and macros for handling architectural difference between compilers, CPUs and operating syst...
STL namespace.
Definition dead_lock_detector.hpp:16
Dead lock detector.
Definition dead_lock_detector.hpp:35
static void clear_stack() noexcept
Clear the stack.
static void * lock(void *object) noexcept
Lock an object on this thread.
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