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"

Calling methods from uint32 FRunnable::Run()?


Does calling an object method in the Run method of FRunnable happen in its own thread that runs the said FRunnable instead of running in the game thread? The method itself is thread-safe, being const & just doing some heavy weight calculations, but it needs to be a method, instead of static, otherwise too much data has to be copied onto the thread. I tried running Sleep inside it & it didn't halt the game thread, but it did halt the worker, so I assume it works correctly, but I'll ask just to be sure none the less.


Product Version: UE 4.14
more ▼

asked Jan 22 '17 at 09:22 PM in C++ Programming

avatar image

78 5 7 10

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

1 answer: sort voted first

It will run on thread which executes Run, which is thread that FRunnable is running

C++ by it self by pure syntax is not support multi-threading, the functions that generate instructions for CPU to create and switch threads or call function in OS that does that is one what makes multi-threading work in C++, but it's not really C++ feature. C++ compiler compiles functions to machine code as they are without even thinking about threading, the called function would need to switch thread on there own to do so, and which as much as i seen ton gameplay code in engine i never seen it using multithreading (well maybe except tick system?).

So your call in Run will simply make current thread jump to function you called, it will does that because CPU instructions generated by compiler will order it to do so.

more ▼

answered Jan 22 '17 at 09:40 PM

avatar image

37.2k 936 172 1116

avatar image Alisaxy Jan 22 '17 at 10:25 PM

Thanks, the last time I used threading was in college... in Java... 5 years ago... I need it because I'm implementing an A* path-finding for flying pawns. With enough nodes & pawns A* can get really heavy. Everything seems to work like a clock for now & the performance is top-notch because I'm using highly optimized heuristics, but even now for a small room it takes around a 1k iterations (I count the amount of times the neighbors have to be iterated, it's of course much less for the upper loop) to get to the goal for a single pawn & that's for like a 25^3 amount of nodes. A* is a beast. That's with my best heuristic that shouldn't work well for maze-like levels. I offer multiple ones that should work well in different situations.

(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