Exemplo n.º 1
0
        public void OnHeartbeat(DateTimeOffset now)
        {
            _now = now;
            Volatile.Write(ref _nowTicks, now.Ticks);

            _connectionManager.Walk(_walkCallback);
        }
Exemplo n.º 2
0
        public static async Task <bool> AbortAllConnectionsAsync(this ConnectionManager connectionManager)
        {
            var abortTasks = new List <Task>();

            connectionManager.Walk(connection =>
            {
                connection.TransportConnection.Abort(new ConnectionAbortedException(CoreStrings.ConnectionAbortedDuringServerShutdown));
                abortTasks.Add(connection.ExecutionTask);
            });

            var allAbortedTask = Task.WhenAll(abortTasks.ToArray());

            return(await Task.WhenAny(allAbortedTask, Task.Delay(1000)).ConfigureAwait(false) == allAbortedTask);
        }
Exemplo n.º 3
0
        public static async Task <bool> CloseAllConnectionsAsync(this ConnectionManager connectionManager, CancellationToken token)
        {
            var closeTasks = new List <Task>();

            connectionManager.Walk(connection =>
            {
                connection.TransportConnection.RequestClose();
                closeTasks.Add(connection.ExecutionTask);
            });

            var allClosedTask = Task.WhenAll(closeTasks.ToArray());

            return(await Task.WhenAny(allClosedTask, CancellationTokenAsTask(token)).ConfigureAwait(false) == allClosedTask);
        }
Exemplo n.º 4
0
 public void OnHeartbeat(DateTimeOffset now)
 {
     _now = now;
     _connectionManager.Walk(_walkCallback);
 }