Multi threading support

Discussion and help for Easy Save 3
Post Reply
teq
Posts: 18
Joined: Mon Jul 16, 2018 12:23 pm

Multi threading support

Post 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.
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Multi threading support

Post 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
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
teq
Posts: 18
Joined: Mon Jul 16, 2018 12:23 pm

Re: Multi threading support

Post 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.
Post Reply