mirror of
https://github.com/Caraxi/mare.client.git
synced 2025-12-12 20:37:22 +01:00
do not paralellize fsw changes
This commit is contained in:
parent
a245e58944
commit
372589d87f
1 changed files with 23 additions and 28 deletions
|
|
@ -249,23 +249,21 @@ public sealed class CacheMonitor : DisposableMediatorSubscriberBase
|
||||||
|
|
||||||
_ = RecalculateFileCacheSize();
|
_ = RecalculateFileCacheSize();
|
||||||
|
|
||||||
|
|
||||||
if (changes.Any(c => c.Value.ChangeType == WatcherChangeTypes.Deleted))
|
if (changes.Any(c => c.Value.ChangeType == WatcherChangeTypes.Deleted))
|
||||||
{
|
{
|
||||||
var threadCount = Math.Clamp((int)(Environment.ProcessorCount / 2.0f), 2, 8);
|
lock (_fileDbManager)
|
||||||
|
|
||||||
Parallel.ForEach(changes, new ParallelOptions()
|
|
||||||
{
|
{
|
||||||
MaxDegreeOfParallelism = threadCount,
|
foreach (var change in changes)
|
||||||
},
|
|
||||||
(change) =>
|
|
||||||
{
|
{
|
||||||
Logger.LogDebug("FSW Change: {change} = {val}", change.Key, change.Value);
|
Logger.LogDebug("FSW Change: {change} = {val}", change.Key, change.Value);
|
||||||
_ = _fileDbManager.GetFileCacheByPath(change.Key);
|
_ = _fileDbManager.GetFileCacheByPath(change.Key);
|
||||||
});
|
}
|
||||||
|
|
||||||
_fileDbManager.WriteOutFullCsv();
|
_fileDbManager.WriteOutFullCsv();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private async Task PenumbraWatcherExecution()
|
private async Task PenumbraWatcherExecution()
|
||||||
{
|
{
|
||||||
|
|
@ -295,13 +293,9 @@ public sealed class CacheMonitor : DisposableMediatorSubscriberBase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var threadCount = Math.Clamp((int)(Environment.ProcessorCount / 2.0f), 2, 8);
|
lock (_fileDbManager)
|
||||||
|
|
||||||
Parallel.ForEach(changes, new ParallelOptions()
|
|
||||||
{
|
{
|
||||||
MaxDegreeOfParallelism = threadCount,
|
foreach (var change in changes)
|
||||||
},
|
|
||||||
(change) =>
|
|
||||||
{
|
{
|
||||||
Logger.LogDebug("FSW Change: {change} = {val}", change.Key, change.Value);
|
Logger.LogDebug("FSW Change: {change} = {val}", change.Key, change.Value);
|
||||||
if (change.Value.ChangeType == WatcherChangeTypes.Deleted)
|
if (change.Value.ChangeType == WatcherChangeTypes.Deleted)
|
||||||
|
|
@ -313,10 +307,11 @@ public sealed class CacheMonitor : DisposableMediatorSubscriberBase
|
||||||
if (change.Value.OldPath != null) _fileDbManager.GetFileCacheByPath(change.Value.OldPath);
|
if (change.Value.OldPath != null) _fileDbManager.GetFileCacheByPath(change.Value.OldPath);
|
||||||
_fileDbManager.CreateFileEntry(change.Key);
|
_fileDbManager.CreateFileEntry(change.Key);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
_fileDbManager.WriteOutFullCsv();
|
_fileDbManager.WriteOutFullCsv();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void InvokeScan()
|
public void InvokeScan()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue