HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
dead_lock_detector.hpp
Go to the documentation of this file.
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
9#pragma once
10
11#include "../utility/module.hpp"
12#include <vector>
13#include <algorithm>
14#include <compare>
15
16namespace hi { inline namespace v1 {
17namespace detail {
18
20 void *before;
21 void *after;
22
23 friend bool operator==(dead_lock_detector_pair const& lhs, dead_lock_detector_pair const& rhs) noexcept = default;
24 friend std::strong_ordering
25 operator<=>(dead_lock_detector_pair const& lhs, dead_lock_detector_pair const& rhs) noexcept = default;
26};
27
28} // namespace detail
29
41public:
47 static void *lock(void *object) noexcept;
48
53 static bool unlock(void *object) noexcept;
54
61 static void remove_object(void *object) noexcept;
62
66 static void clear_stack() noexcept;
67
71 static void clear_graph() noexcept;
72
73private:
74 thread_local inline static std::vector<void *> stack;
75
81 inline static std::vector<detail::dead_lock_detector_pair> lock_graph;
82
83 [[nodiscard]] static void *check_graph(void *object) noexcept;
84};
85
86}} // namespace hi::v1
STL namespace.
DOXYGEN BUG.
Definition algorithm.hpp:13
geometry/margins.hpp
Definition cache.hpp:11
Definition dead_lock_detector.hpp:19
Dead lock detector.
Definition dead_lock_detector.hpp:40
static void clear_graph() noexcept
Clear the graph.
static bool unlock(void *object) noexcept
Unlock an object on this thread.
static void remove_object(void *object) noexcept
Remove the object from the detection.
static void * lock(void *object) noexcept
Lock an object on this thread.
static void clear_stack() noexcept
Clear the stack.