|
@ -27,10 +27,8 @@ namespace IPA.Config |
|
|
|
|
|
|
|
|
private static readonly ConcurrentBag<Config> configs = new(); |
|
|
private static readonly ConcurrentBag<Config> configs = new(); |
|
|
private static readonly AutoResetEvent configsChangedWatcher = new(false); |
|
|
private static readonly AutoResetEvent configsChangedWatcher = new(false); |
|
|
private static readonly ConcurrentDictionary<DirectoryInfo, FileSystemWatcher> watchers |
|
|
|
|
|
= new ConcurrentDictionary<DirectoryInfo, FileSystemWatcher>(new DirInfoEqComparer()); |
|
|
|
|
|
private static readonly ConcurrentDictionary<FileSystemWatcher, ConcurrentBag<Config>> watcherTrackConfigs |
|
|
|
|
|
= new ConcurrentDictionary<FileSystemWatcher, ConcurrentBag<Config>>(); |
|
|
|
|
|
|
|
|
private static readonly ConcurrentDictionary<DirectoryInfo, FileSystemWatcher> watchers = new(new DirInfoEqComparer()); |
|
|
|
|
|
private static readonly ConcurrentDictionary<FileSystemWatcher, ConcurrentBag<Config>> watcherTrackConfigs = new(); |
|
|
private static BlockingCollection<IConfigStore> requiresSave = new(); |
|
|
private static BlockingCollection<IConfigStore> requiresSave = new(); |
|
|
private static SingleThreadTaskScheduler loadScheduler; |
|
|
private static SingleThreadTaskScheduler loadScheduler; |
|
|
private static TaskFactory loadFactory; |
|
|
private static TaskFactory loadFactory; |
|
@ -82,13 +80,14 @@ namespace IPA.Config |
|
|
|
|
|
|
|
|
loadScheduler.Join(); // we can wait for the loads to finish
|
|
|
loadScheduler.Join(); // we can wait for the loads to finish
|
|
|
saveThread.Abort(); // eww, but i don't like any of the other potential solutions
|
|
|
saveThread.Abort(); // eww, but i don't like any of the other potential solutions
|
|
|
|
|
|
legacySaveThread.Abort(); |
|
|
|
|
|
|
|
|
SaveAll(); |
|
|
SaveAll(); |
|
|
|
|
|
|
|
|
requiresSave.Dispose(); |
|
|
requiresSave.Dispose(); |
|
|
requiresSave = null; |
|
|
requiresSave = null; |
|
|
} |
|
|
} |
|
|
catch |
|
|
|
|
|
|
|
|
catch |
|
|
{ |
|
|
{ |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -237,7 +236,7 @@ namespace IPA.Config |
|
|
{ |
|
|
{ |
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
|
Save(configs.First((c) => ReferenceEquals(c.Store.WriteSyncObject, item.WriteSyncObject))); |
|
|
|
|
|
|
|
|
Save(configs.First((c) => c.Store != null && ReferenceEquals(c.Store.WriteSyncObject, item.WriteSyncObject))); |
|
|
} |
|
|
} |
|
|
catch (ThreadAbortException) |
|
|
catch (ThreadAbortException) |
|
|
{ |
|
|
{ |
|
@ -263,7 +262,7 @@ namespace IPA.Config |
|
|
{ |
|
|
{ |
|
|
while (true) |
|
|
while (true) |
|
|
{ |
|
|
{ |
|
|
var configArr = configs.Where(c => c.Store != null).Where(c => c.Store.SyncObject != null).ToArray(); |
|
|
|
|
|
|
|
|
var configArr = configs.Where(c => c.Store?.SyncObject != null).ToArray(); |
|
|
int index = -1; |
|
|
int index = -1; |
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
|