mirror of
https://github.com/Caraxi/mare.client.git
synced 2025-12-13 19:54:15 +01:00
the need for speed
This commit is contained in:
parent
de2cd97dbe
commit
3715ca5ce3
8 changed files with 82 additions and 102 deletions
|
|
@ -14,6 +14,7 @@ namespace MareSynchronos.PlayerData.Pairs;
|
|||
public class Pair
|
||||
{
|
||||
private readonly Func<OnlineUserIdentDto, CachedPlayer> _cachedPlayerFactory;
|
||||
private readonly SemaphoreSlim _creationSemaphore = new(1);
|
||||
private readonly ILogger<Pair> _logger;
|
||||
private readonly MareMediator _mediator;
|
||||
private readonly ServerConfigurationManager _serverConfigurationManager;
|
||||
|
|
@ -89,19 +90,28 @@ public class Pair
|
|||
|
||||
public void CreateCachedPlayer(OnlineUserIdentDto? dto = null)
|
||||
{
|
||||
if (dto == null && _onlineUserIdentDto == null)
|
||||
try
|
||||
{
|
||||
CachedPlayer?.Dispose();
|
||||
CachedPlayer = null;
|
||||
return;
|
||||
}
|
||||
if (dto != null)
|
||||
{
|
||||
_onlineUserIdentDto = dto;
|
||||
}
|
||||
_creationSemaphore.Wait();
|
||||
|
||||
CachedPlayer?.Dispose();
|
||||
CachedPlayer = _cachedPlayerFactory(_onlineUserIdentDto!);
|
||||
if (dto == null && _onlineUserIdentDto == null)
|
||||
{
|
||||
CachedPlayer?.Dispose();
|
||||
CachedPlayer = null;
|
||||
return;
|
||||
}
|
||||
if (dto != null)
|
||||
{
|
||||
_onlineUserIdentDto = dto;
|
||||
}
|
||||
|
||||
CachedPlayer?.Dispose();
|
||||
CachedPlayer = _cachedPlayerFactory(_onlineUserIdentDto!);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_creationSemaphore.Release();
|
||||
}
|
||||
}
|
||||
|
||||
public string? GetNote()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue