Page 1 of 1

Multi threading support

Posted: Tue Sep 17, 2019 2:48 pm
by teq
In ES3Settings file i changed "return Application.persistentDataPath + "/" + path;" to "return ES3.persistentDataPath + "/" + path;"
and "return Application.dataPath + "/" + path;" to "return ES3.dataPath + "/" + path;".
In ES3 file added

Code: Select all

public static string persistentDataPath = Application.persistentDataPath;
	public static string dataPath = Application.dataPath;
Same change also need to be done in GetPath file, line with "if(directoryPath != UnityEngine.Application.persistentDataPath)"

It can be used in another threads now. Please, add this to the next version.

Re: Multi threading support

Posted: Tue Sep 17, 2019 5:35 pm
by Joel
Hi there,

I wasn't aware that Application.persistentDataPath wasn't thread safe, as we've been told that it essentially works as your solution proposes underneath. Would you be able to point me towards where it says it isn't thread safe?

All the best,
Joel

Re: Multi threading support

Posted: Tue Sep 17, 2019 7:16 pm
by teq
It's from asset https://assetstore.unity.com/packages/t ... ding-20857. I don't know, how it behaves with "native" threading.
get_persistentDataPath can only be called from the main thread.
Constructors and field initializers will be executed from the loading thread when loading a scene.
Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function.