From 5ca0a45606ad2ca7e1ca45a3b27be08e9640dd9d Mon Sep 17 00:00:00 2001 From: Rory& Date: Thu, 25 Apr 2024 06:31:11 +0200 Subject: Fixes --- LibMatrix/Homeservers/AuthenticatedHomeserverGeneric.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'LibMatrix/Homeservers') 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 GetJoinedRoomsByType(string type) { + public virtual async IAsyncEnumerable 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; } -- cgit 1.4.1