mirror of
https://github.com/Caraxi/mare.client.git
synced 2025-12-12 19:57:23 +01:00
fix potential cancelaltion on updateshareddata
This commit is contained in:
parent
4a2cd80def
commit
722f3ec338
1 changed files with 17 additions and 8 deletions
|
|
@ -28,6 +28,7 @@ public sealed class CharaDataNearbyManager : DisposableMediatorSubscriberBase
|
|||
private Task? _filterEntriesRunningTask;
|
||||
private (Guid VfxId, PoseEntryExtended Pose)? _hoveredVfx = null;
|
||||
private DateTime _lastExecutionTime = DateTime.UtcNow;
|
||||
private SemaphoreSlim _sharedDataUpdateSemaphore = new(1, 1);
|
||||
public CharaDataNearbyManager(ILogger<CharaDataNearbyManager> logger, MareMediator mediator,
|
||||
DalamudUtilService dalamudUtilService, VfxSpawnManager vfxSpawnManager,
|
||||
ServerConfigurationManager serverConfigurationManager,
|
||||
|
|
@ -50,17 +51,25 @@ public sealed class CharaDataNearbyManager : DisposableMediatorSubscriberBase
|
|||
|
||||
public void UpdateSharedData(Dictionary<string, CharaDataMetaInfoExtendedDto?> newData)
|
||||
{
|
||||
_metaInfoCache.Clear();
|
||||
foreach (var kvp in newData)
|
||||
_sharedDataUpdateSemaphore.Wait();
|
||||
try
|
||||
{
|
||||
if (kvp.Value == null) continue;
|
||||
|
||||
if (!_metaInfoCache.TryGetValue(kvp.Value.Uploader, out var list))
|
||||
_metaInfoCache.Clear();
|
||||
foreach (var kvp in newData)
|
||||
{
|
||||
_metaInfoCache[kvp.Value.Uploader] = list = [];
|
||||
}
|
||||
if (kvp.Value == null) continue;
|
||||
|
||||
list.Add(kvp.Value);
|
||||
if (!_metaInfoCache.TryGetValue(kvp.Value.Uploader, out var list))
|
||||
{
|
||||
_metaInfoCache[kvp.Value.Uploader] = list = [];
|
||||
}
|
||||
|
||||
list.Add(kvp.Value);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
_sharedDataUpdateSemaphore.Release();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue