about summary refs log tree commit diff
path: root/LibMatrix/Homeservers/AuthenticatedHomeserverGeneric.cs
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2024-04-25 06:31:11 +0200
committerRory& <root@rory.gay>2024-04-25 06:31:11 +0200
commit5ca0a45606ad2ca7e1ca45a3b27be08e9640dd9d (patch)
tree6a04296d6fd93cb090b5d91ae9ca44ef45c7e34e /LibMatrix/Homeservers/AuthenticatedHomeserverGeneric.cs
parentPartial User-Interactive Authentication, allow skipping homeserver typing (diff)
downloadLibMatrix-5ca0a45606ad2ca7e1ca45a3b27be08e9640dd9d.tar.xz
Fixes
Diffstat (limited to 'LibMatrix/Homeservers/AuthenticatedHomeserverGeneric.cs')
-rw-r--r--LibMatrix/Homeservers/AuthenticatedHomeserverGeneric.cs5
1 files changed, 4 insertions, 1 deletions
diff --git a/LibMatrix/Homeservers/AuthenticatedHomeserverGeneric.cs b/LibMatrix/Homeservers/AuthenticatedHomeserverGeneric.cs
index 267b54d..5520d3a 100644
--- a/LibMatrix/Homeservers/AuthenticatedHomeserverGeneric.cs
+++ b/LibMatrix/Homeservers/AuthenticatedHomeserverGeneric.cs
@@ -125,12 +125,15 @@ public class AuthenticatedHomeserverGeneric : RemoteHomeserver {
 
 #region Utility Functions
 
-    public virtual async IAsyncEnumerable<GenericRoom> GetJoinedRoomsByType(string type) {
+    public virtual async IAsyncEnumerable<GenericRoom> GetJoinedRoomsByType(string type, int? semaphoreCount = null) {
         var rooms = await GetJoinedRooms();
+        SemaphoreSlim? semaphoreSlim = semaphoreCount is null ? null : new(semaphoreCount.Value, semaphoreCount.Value);
         var tasks = rooms.Select(async room => {
             while (true) {
+                if (semaphoreSlim is not null) await semaphoreSlim.WaitAsync();
                 try {
                     var roomType = await room.GetRoomType();
+                    if (semaphoreSlim is not null) semaphoreSlim.Release();
                     if (roomType == type) return room;
                     return null;
                 }