Common::Event: Add a faster Windows specific implementation based on the concurrency runtime.
This commit is contained in:
parent
48bd904028
commit
7074feacbe
|
@ -12,13 +12,20 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <concrt.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "Common/Flag.h"
|
#include "Common/Flag.h"
|
||||||
#include "Common/StdConditionVariable.h"
|
#include "Common/StdConditionVariable.h"
|
||||||
#include "Common/StdMutex.h"
|
#include "Common/StdMutex.h"
|
||||||
|
|
||||||
namespace Common {
|
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:
|
public:
|
||||||
void Set()
|
void Set()
|
||||||
|
@ -53,5 +60,17 @@ private:
|
||||||
std::condition_variable m_condvar;
|
std::condition_variable m_condvar;
|
||||||
std::mutex m_mutex;
|
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
|
} // namespace Common
|
||||||
|
|
Loading…
Reference in New Issue