I was using the
std::mutex for the code that I’m using.
std::thread has an
#include concrt.h statement inside of its header. So Unreal gives me the error:
C2872: 'DWORD' : ambiguous symbol C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\concrt.h 5248
So I’m wondering how can I create a thread and a mutex for a non-unreal code that I’m using? I’ve read
FPThreadsCriticalSection is the way to do it.
How do I do that?
Thanks in advance.
DWORD may be masked by Unreal. You can make it visible by including these lines:
But if you just want to use a mutex,
FPThreadsCriticalSection is the way to go; unless your trying to include a third-party library that require
std::mutex. A critical section is a single process mutex, so it’s faster that asking the OS to create a resource just to synchronize two threads in the same process. You always can include your project
.h in any file to have access to the
Core Unreal module.
I have made an example on how to use FCriticalSection and FEvent:
MultiThreading and synchronization Guide hope it might be helpful for future users.