diff options
Diffstat (limited to 'LibMatrix/Homeservers/AuthenticatedHomeserverGeneric.cs')
-rw-r--r-- | LibMatrix/Homeservers/AuthenticatedHomeserverGeneric.cs | 5 |
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; } |