HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
src
TTauri
Foundation
fast_mutex.hpp
1
// Copyright 2020 Pokitec
2
// All rights reserved.
3
4
#pragma once
5
6
#include "TTauri/Foundation/required.hpp"
7
#include <atomic>
8
#include <memory>
9
#include <thread>
10
11
namespace
tt {
12
struct
unfair_lock_wrap;
13
14
class
fast_mutex
{
15
#if TT_OPERATING_SYSTEM == TT_OS_WINDOWS
16
std::atomic<int32_t>
semaphore = 0;
17
18
int32_t *semaphore_ptr()
noexcept
{
19
return
reinterpret_cast<
int32_t *
>
(&semaphore);
20
}
21
22
void
lock_contented(int32_t first)
noexcept
;
23
24
#elif TT_OPERATING_SYSTEM == TT_OS_MACOS
25
std::unique_ptr<unfair_lock_wrap>
mutex;
26
27
#else
28
#error "Not implemented fast_mutex"
29
#endif
30
31
#if TT_BUILD_TYPE == TT_BT_DEBUG
32
std::thread::id
locking_thread;
33
#endif
34
35
public
:
36
fast_mutex
()
noexcept
;
37
~fast_mutex
();
38
39
void
lock()
noexcept
;
40
41
void
unlock()
noexcept
;
42
};
43
44
45
};
tt::fast_mutex
Definition
fast_mutex.hpp:14
std::atomic
std::thread::id
std::unique_ptr
Generated on Mon Apr 22 2024 12:53:56 for HikoGUI by
1.10.0