diff options
| author | lizzie <lizzie@eden-emu.dev> | 2026-05-30 21:59:10 +0200 |
|---|---|---|
| committer | crueter <crueter@eden-emu.dev> | 2026-05-30 21:59:10 +0200 |
| commit | 7c32cf03a1ce2a88b5bda041a5aebc8405fe634d (patch) | |
| tree | 8eabbb338cceebd7f018a7c442a304fd66c68adc /src/common/thread.h | |
| parent | ff7bbaea7db5a9a9528c1ef087d3a49a18931b52 (diff) | |
[core/core_timing] better MWAITX and WAITPKG delays (#3984)
This implements MWAITX and WAITPKG extensions (umonitor, mwait) for CPUs that support them.
Reduces wait times and bypasses the timing stuff from the OS that is slow (windows notably). generally it should answer within 0.2 to 0.5 microsecs (since most requests wait for that long).
Also does a general rework of static ctors and stuff
Signed-off-by: lizzie <lizzie@eden-emu.dev>
Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3984
Reviewed-by: MaranBr <maranbr@eden-emu.dev>
Reviewed-by: crueter <crueter@eden-emu.dev>
Diffstat (limited to 'src/common/thread.h')
| -rw-r--r-- | src/common/thread.h | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/src/common/thread.h b/src/common/thread.h index ea6f5d6b3b..a75e342802 100644 --- a/src/common/thread.h +++ b/src/common/thread.h @@ -34,16 +34,10 @@ public: is_set = false; } - bool WaitFor(const std::chrono::nanoseconds& time) { - std::unique_lock lk{mutex}; - if (!condvar.wait_for(lk, time, [this] { return is_set.load(); })) - return false; - is_set = false; - return true; - } + bool WaitFor(const std::chrono::nanoseconds time); - template <class Clock, class Duration> - bool WaitUntil(const std::chrono::time_point<Clock, Duration>& time) { + template<class Clock, class Duration> + bool WaitUntil(const std::chrono::time_point<Clock, Duration> time) { std::unique_lock lk{mutex}; if (!condvar.wait_until(lk, time, [this] { return is_set.load(); })) return false; @@ -63,9 +57,9 @@ public: } private: + alignas(64) std::atomic<bool> is_set{false}; std::condition_variable condvar; std::mutex mutex; - std::atomic_bool is_set{false}; }; class Barrier { |
