From 7074feacbebb1521a7c041c13237e799b7299d56 Mon Sep 17 00:00:00 2001 From: Pierre Bourdon Date: Mon, 14 Apr 2014 02:30:40 +0200 Subject: [PATCH] Common::Event: Add a faster Windows specific implementation based on the concurrency runtime. --- Source/Core/Common/Event.h | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/Source/Core/Common/Event.h b/Source/Core/Common/Event.h index 8499fdb1e8..b60a7cacd3 100644 --- a/Source/Core/Common/Event.h +++ b/Source/Core/Common/Event.h @@ -12,13 +12,20 @@ #pragma once +#ifdef _WIN32 +#include +#endif + #include "Common/Flag.h" #include "Common/StdConditionVariable.h" #include "Common/StdMutex.h" namespace Common { -class Event +// Windows uses a specific implementation because std::condition_variable has +// terrible performance for this kind of workload with MSVC++ 2013. +#ifndef _WIN32 +class Event final { public: void Set() @@ -53,5 +60,17 @@ private: std::condition_variable m_condvar; std::mutex m_mutex; }; +#else +class Event final +{ +public: + void Set() { m_event.set(); } + void Wait() { m_event.wait(); m_event.reset(); } + void Reset() { m_event.reset(); } + +private: + concurrency::event m_event; +}; +#endif } // namespace Common