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"

FRunnableThread Structs corrupting/unsafe?

Hi Guys,

I've been working on taking my procedural generation out of the game thread and giving it its own thread to improve FPS and reduce stuttering. However I appear to be getting some sort of corruption or issue with the values I am setting within the thread.

In my run() i just take the job from the queue store it in a private variable and start this sub method:

 bool IsComplete = false;
 float PlacementValue = workJob.MinPlacementValue;

 while (IsComplete == false)
     for (int32 i = 0; i < workJob.PlacementAttempts; i++)
         UE_LOG(LogTemp, Error, TEXT("pre calc place XLoc is %i"), workJob.BuildingLocation->XLocation);
         //if (CalculatePlacement(PlacementValue))
         //    IsComplete = true;
         //    break;
         UE_LOG(LogTemp, Error, TEXT("TempTest XLoc is %i"), workJob.BuildingLocation->XLocation);

The SetupParamsForInterestCalc() method basically sets the XLocation on the workJob (taken from the thread queue).

Somehow between the first log and the second log the correct value which is being set in the SetupParamsForInterestCalc(); method is being corrupted or changed to 0. This is very strange given that no other code is running in the thread between these two logs.

The stranger thing is that before I commented out the calculate placement method I used breakpoints upon entering the method for which the variable was fine, and then upon the first line of code it was strangely changing to -2 every time.

I don't understand how this is possible given the private nature of the variable and the lack of other processes. The workJob and buildinglocation variables are simply structs (not even ustructs).

If anyone knows what this issue is or how I can fix it then please help!



Product Version: UE 4.19
more ▼

asked Oct 07 '18 at 08:12 PM in C++ Programming

avatar image


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

1 answer: sort voted first

Edit, I changed the "buildinglocation" struct from a pointer to a struct object and this has somehow fixed the problem (no references to the struct in the game thread) so I will be closing this question.

more ▼

answered Oct 08 '18 at 06:37 AM

avatar image


(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