diff options
author | TheArcaneBrony <myrainbowdash949@gmail.com> | 2023-09-04 02:17:10 +0200 |
---|---|---|
committer | TheArcaneBrony <myrainbowdash949@gmail.com> | 2023-09-04 02:17:10 +0200 |
commit | 21da6cde79ccd0cb7f895a29e3d8cab959ef11ba (patch) | |
tree | fb0b89566b64ae907d7ca3ea8a29adcf0c0361d0 /LibMatrix/Services/HomeserverResolverService.cs | |
parent | Clean up some extension functions (diff) | |
download | LibMatrix-21da6cde79ccd0cb7f895a29e3d8cab959ef11ba.tar.xz |
Too many changes to name...
Diffstat (limited to 'LibMatrix/Services/HomeserverResolverService.cs')
-rw-r--r-- | LibMatrix/Services/HomeserverResolverService.cs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/LibMatrix/Services/HomeserverResolverService.cs b/LibMatrix/Services/HomeserverResolverService.cs index 78c5c37..dcd0fe9 100644 --- a/LibMatrix/Services/HomeserverResolverService.cs +++ b/LibMatrix/Services/HomeserverResolverService.cs @@ -1,4 +1,10 @@ +using System; +using System.Collections.Generic; +using System.IO; using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using ArcaneLibs.Extensions; using LibMatrix.Extensions; using Microsoft.Extensions.Logging; @@ -26,9 +32,9 @@ public class HomeserverResolverService { if (homeserver is null) throw new ArgumentNullException(nameof(homeserver)); var sem = _wellKnownSemaphores.GetOrCreate(homeserver, _ => new SemaphoreSlim(1, 1)); await sem.WaitAsync(); - if (_wellKnownCache.ContainsKey(homeserver)) { + if (_wellKnownCache.TryGetValue(homeserver, out var known)) { sem.Release(); - return _wellKnownCache[homeserver]; + return known; } string? result = null; |