Is autoload singleton script thread-safe?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By zeruno

I am creating a Singleton (Autoload) as in this official documentation. I am creating a scoreboard and tracking the number of enemies killed. Whenever an enemy is killed, the scoreboard value is incremented. Is this implementation prone to race conditions, does Godot provide thread-safety here? Or should I take additional precautions?

:bust_in_silhouette: Reply From: Gluon

Per the godot docs here

you can see it states the following;

Global Scope singletons are all thread-safe. Accessing servers from threads is supported (for VisualServer and Physics servers, ensure threaded or thread-safe operation is enabled in the project settings!).

So the short answer is yes.