Files
MTSC/MTSC/ServerSide/Schedulers/ParallelScheduler.cs
T
Alexandru Macocian e5ccfff5da - stop redundant parsing of HttpRequests for HttpRoutingHandler
- introduced handler affinity to let handlers claim a client and prevent other handlers from receiving messages from the client
- Httproutinghandler will route based on headers without loading the entire message
2020-04-09 18:48:36 +02:00

24 lines
740 B
C#

using MTSC.Common;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace MTSC.ServerSide.Schedulers
{
public class ParallelScheduler : IScheduler
{
void IScheduler.ScheduleHandling(List<(ClientData, IConsumerQueue<Message>)> clientsQueues, Action<ClientData, IConsumerQueue<Message>> messageHandlingProcedure)
{
List<Action> actionList = new List<Action>();
foreach(var tuple in clientsQueues)
{
(var client, var messageQueue) = tuple;
actionList.Add(new Action(() => messageHandlingProcedure.Invoke(client, messageQueue)));
}
Parallel.Invoke(actionList.ToArray());
}
}
}