diff --git a/IPA.Loader/Config/ConfigRuntime.cs b/IPA.Loader/Config/ConfigRuntime.cs index 8f8bf640..6033c181 100644 --- a/IPA.Loader/Config/ConfigRuntime.cs +++ b/IPA.Loader/Config/ConfigRuntime.cs @@ -26,13 +26,12 @@ namespace IPA.Config } private static readonly ConcurrentBag configs = new ConcurrentBag(); - private static readonly Action configsChangedWatcher = () => + private static readonly Action configsChangedAction = () => { foreach (var config in configs.Where(c => c.Store != null).ToArray()) - { config.Store.SyncAction = () => RequiresSave.Add(() => Save(config)); - } }; + private static readonly BlockingCollection RequiresSave = new(); private static readonly ConcurrentDictionary watchers = new ConcurrentDictionary(new DirInfoEqComparer()); private static readonly ConcurrentDictionary> watcherTrackConfigs @@ -93,7 +92,7 @@ namespace IPA.Config configs.Add(cfg); } - configsChangedWatcher?.Invoke(); + configsChangedAction.Invoke(); TryStartRuntime(); @@ -102,7 +101,7 @@ namespace IPA.Config public static void ConfigChanged() { - configsChangedWatcher.Invoke(); + configsChangedAction.Invoke(); } private static void AddConfigToWatchers(Config config) @@ -215,16 +214,11 @@ namespace IPA.Config } } - static readonly BlockingCollection RequiresSave = new(); - private static void SaveThread() { try { - var configArr = configs.Where(c => c.Store != null).ToArray(); - - configsChangedWatcher.Invoke(); - + configsChangedAction.Invoke(); foreach (var item in RequiresSave.GetConsumingEnumerable()) { try diff --git a/IPA.Loader/Config/Stores/GeneratedStoreImpl/IGeneratedStore.cs b/IPA.Loader/Config/Stores/GeneratedStoreImpl/IGeneratedStore.cs index 39162cf4..c28e8455 100644 --- a/IPA.Loader/Config/Stores/GeneratedStoreImpl/IGeneratedStore.cs +++ b/IPA.Loader/Config/Stores/GeneratedStoreImpl/IGeneratedStore.cs @@ -55,11 +55,9 @@ namespace IPA.Config.Stores var impl = FindImpl(s); if (impl != null) impl.SyncAction = value; } - internal static MethodInfo ImplGetSyncObjectMethod = typeof(Impl).GetMethod(nameof(ImplGetSyncObject)); internal static MethodInfo ImplSetSyncActionMethod = typeof(Impl).GetMethod(nameof(ImplSetSyncAction)); - public ReaderWriterLockSlim WriteSyncObject { get; } = new(); public static ReaderWriterLockSlim? ImplGetWriteSyncObject(IGeneratedStore s) => FindImpl(s)?.WriteSyncObject; internal static MethodInfo ImplGetWriteSyncObjectMethod = typeof(Impl).GetMethod(nameof(ImplGetWriteSyncObject));