Browse Source

Cleanup

pull/101/head
Arimodu 7 months ago
parent
commit
52e64e591b
2 changed files with 5 additions and 13 deletions
  1. +5
    -11
      IPA.Loader/Config/ConfigRuntime.cs
  2. +0
    -2
      IPA.Loader/Config/Stores/GeneratedStoreImpl/IGeneratedStore.cs

+ 5
- 11
IPA.Loader/Config/ConfigRuntime.cs View File

@ -26,13 +26,12 @@ namespace IPA.Config
}
private static readonly ConcurrentBag<Config> configs = new ConcurrentBag<Config>();
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<Action> RequiresSave = new();
private static readonly ConcurrentDictionary<DirectoryInfo, FileSystemWatcher> watchers
= new ConcurrentDictionary<DirectoryInfo, FileSystemWatcher>(new DirInfoEqComparer());
private static readonly ConcurrentDictionary<FileSystemWatcher, ConcurrentBag<Config>> 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<Action> 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


+ 0
- 2
IPA.Loader/Config/Stores/GeneratedStoreImpl/IGeneratedStore.cs View File

@ -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));


Loading…
Cancel
Save