HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
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
11namespace tt {
12struct unfair_lock_wrap;
13
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
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
35public:
36 fast_mutex() noexcept;
38
39 void lock() noexcept;
40
41 void unlock() noexcept;
42};
43
44
45};
Definition fast_mutex.hpp:14