libER 0.1.4.2
ELDEN RING API library
Loading...
Searching...
No Matches
kernel_runtime.hpp
Go to the documentation of this file.
1
8#pragma once
9
11#include <detail/preprocessor.hpp>
12
13// Part of namespace DLKR and DLKRD
15
16// Forward declarations to not include Windows.h
17struct _RTL_CRITICAL_SECTION;
18
20using HANDLE = void*;
22
23namespace from {
24// Windows Kernel runtime functionality;
25// mutexes, signals, allocators etc.
26namespace DLKR {
27// Non-copyable dummy (empty) synchronization object
29
39public:
40 LIBER_CLASS(DLPlainLightMutex);
41
42 LIBERAPI DLPlainLightMutex() noexcept;
43
50 LIBERAPI explicit DLPlainLightMutex(int spin_count) noexcept;
51
52 LIBERAPI virtual ~DLPlainLightMutex() noexcept;
53
59 LIBERAPI void lock() noexcept;
60
66 LIBERAPI void unlock() noexcept;
67
76 [[nodiscard]] LIBERAPI bool try_lock() noexcept;
77
78 DLPlainLightMutex(DLPlainLightMutex&&) noexcept = delete;
79
80private:
81 _RTL_CRITICAL_SECTION* critical_section() noexcept {
82 return this->_dummy_section.get();
83 }
84
85 struct alignas(8) _critical_section {
86 char _dummy_section_bytes[0x28];
87
88 _RTL_CRITICAL_SECTION* get() noexcept {
89 return reinterpret_cast<_RTL_CRITICAL_SECTION*>(this);
90 }
91 } _dummy_section;
92};
93
94LIBER_ASSERTS_BEGIN(DLPlainLightMutex);
95LIBER_ASSERT_SIZE(0x30);
96LIBER_ASSERTS_END;
97
107public:
108 LIBER_CLASS(DLPlainMutex);
109
110 LIBERAPI DLPlainMutex() noexcept;
111
112 LIBERAPI virtual ~DLPlainMutex() noexcept;
113
119 LIBERAPI void lock() noexcept;
120
126 LIBERAPI void unlock() noexcept;
127
136 [[nodiscard]] LIBERAPI bool try_lock() noexcept;
137
138 DLPlainMutex(DLPlainMutex&&) noexcept = delete;
139
140private:
141 HANDLE mutex_handle;
142};
143
144LIBER_ASSERTS_BEGIN(DLPlainMutex);
145LIBER_ASSERT_SIZE(0x10);
146LIBER_ASSERTS_END;
147
157public:
158 LIBER_CLASS(DLPlainAdaptiveMutex);
159
160 DLPlainAdaptiveMutex() noexcept
161 : DLPlainLightMutex(4000), spin_count(4000) {}
162
169 explicit DLPlainAdaptiveMutex(int spin_count) noexcept
170 : DLPlainLightMutex(spin_count), spin_count(spin_count) {}
171
172 virtual ~DLPlainAdaptiveMutex() noexcept = default;
173
174 DLPlainAdaptiveMutex(DLPlainAdaptiveMutex&&) noexcept = delete;
175
176private:
177 int spin_count;
178};
179
180LIBER_ASSERTS_BEGIN(DLPlainAdaptiveMutex);
181LIBER_ASSERT_SIZE(0x38);
182LIBER_ASSERTS_END;
183} // namespace DLKR
184} // namespace from
Definition kernel_runtime.hpp:28
A wrapper around a Windows Critical Section (with a spincount).
Definition kernel_runtime.hpp:156
DLPlainAdaptiveMutex(int spin_count) noexcept
Initialize the Windows Critical Section with an explicit spin count.
Definition kernel_runtime.hpp:169
A wrapper around a Windows Critical Section.
Definition kernel_runtime.hpp:38
LIBERAPI void unlock() noexcept
Unlock the mutex.
LIBERAPI void lock() noexcept
Lock the mutex.
LIBERAPI DLPlainLightMutex(int spin_count) noexcept
Initialize the Windows Critical Section with an explicit spin count.
LIBERAPI bool try_lock() noexcept
Try to lock the mutex.
A wrapper around a Windows kernel mutex.
Definition kernel_runtime.hpp:106
LIBERAPI bool try_lock() noexcept
Try to lock the mutex.
LIBERAPI void lock() noexcept
Lock the mutex.
LIBERAPI void unlock() noexcept
Unlock the mutex.
Base class used for non-copyable, but movable objects.
Definition utility.hpp:27
ELDEN RING allocation interface and from::allocator.
Dantelion2 utility.