private IEnumerator <object> ListenerTask(ListenerContext context) { using (context) { yield return(Future.RunInThread(context.Start)); var wfns = new WaitForNextStep(); var acceptedConnections = new List <IncomingConnection>(); const int connectionsToAcceptPerStep = 4; Future <IncomingConnection> acceptedConnection = null; while (true) { if (acceptedConnection != null) { if (acceptedConnection.Failed) { OnListenerError(acceptedConnection.Error); } else { acceptedConnections.Add(acceptedConnection.Result); } } context.IncomingConnections.DequeueMultiple( acceptedConnections, connectionsToAcceptPerStep ); foreach (var ac in acceptedConnections) { var fKeepAlive = Scheduler.Start(KeepAliveTask(context, ac)); fKeepAlive.RegisterOnComplete(RequestOnComplete); } acceptedConnections.Clear(); acceptedConnection = context.IncomingConnections.Dequeue(); yield return(acceptedConnection); } } }
private IEnumerator<object> ListenerTask(ListenerContext context) { using (context) { yield return Future.RunInThread(context.Start); var wfns = new WaitForNextStep(); var acceptedConnections = new List<IncomingConnection>(); const int connectionsToAcceptPerStep = 4; Future<IncomingConnection> acceptedConnection = null; while (true) { if (acceptedConnection != null) { if (acceptedConnection.Failed) OnListenerError(acceptedConnection.Error); else acceptedConnections.Add(acceptedConnection.Result); } context.IncomingConnections.DequeueMultiple( acceptedConnections, connectionsToAcceptPerStep ); foreach (var ac in acceptedConnections) { var fKeepAlive = Scheduler.Start(KeepAliveTask(context, ac)); fKeepAlive.RegisterOnComplete(RequestOnComplete); } acceptedConnections.Clear(); acceptedConnection = context.IncomingConnections.Dequeue(); yield return acceptedConnection; } } }