x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

C++ How to create thread and mutex?

Greetings,

I was using the std::thread and std::mutex for the code that I'm using.

But apparently 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.

Product Version: Not Selected
Tags:
more ▼

asked Mar 03 '15 at 03:20 PM in C++ Programming

avatar image

CanMetan
91 9 58 15

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

Hi there,

I have made an example on how to use FCriticalSection and FEvent: MultiThreading and synchronization Guide hope it might be helpful for future users.

more ▼

answered Apr 16 '17 at 10:18 PM

avatar image

ColdSteel48
537 6 19 23

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

DWORD may be masked by Unreal. You can make it visible by including these lines:

 #include "AllowWindowsPlatformTypes.h" 
  #include <thread>
  #include "HideWindowsPlatformTypes.h"

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.

more ▼

answered Mar 13 '15 at 07:49 PM

avatar image

tunel
16 3

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question