Need some info about Unreal 4s threads and thread-safety

In my current project i want to use a third-party library (Lua) for modding-capabilities, which would include ai, actors aswell as ui widgets,

The problem i have is : Accessing a Lua state is not thread-safe, it should be accessed by only one thread at any given time (that includes reading and writing). I only need it for gameplay logic/ai logic/behavior trees and UI.

I only know that in Unreal 4 rendering is done in a separate thread (which is something my lua state wouldn’t come in touch with at all so no problem there) and i read that physics area also done on a separate thread, but i’m unsure about the rest.

Now the question : is all the game logic, like all the tick-events/tick-functions, aka
-player controller lotic,
-ai controller logic,
-player controller logic,
-character/actor logic
-animation logic,
-the ai behavior tree logic/BHT tasks and
-UMG-widget logic
on the same thread in Unreal 4?

If not, is there any page that shows what threads Unreal 4 has for what engine feature so i can make some proper adjustments?

The only helpful answer i found so far was this topic
https://forums.unrealengine.com/show...nd-Job-Threads
but they didn’t seem to be 100% sure and before i stumble into errors or make unneccessary adjustments i want to make sure.

No one knows?

Yes, all Game Logic afaik is run in Main Thread.

Also you can use FFunctionGraphTask::CreateAndDispatchWhenReady to run delegates in MainThread (some form of async run)

	FClientObjectDelegate DelegateCopy = OnConnected;
	if (DelegateCopy.IsBound())
	{
		FFunctionGraphTask::CreateAndDispatchWhenReady([DelegateCopy, this]() { DelegateCopy.ExecuteIfBound(this); }, TStatId(), nullptr, ENamedThreads::GameThread);
	}

Alright. Thank you very much!!! :slight_smile:

Didn’t know about that. Thank you so much for the tip! :slight_smile: