Github user jorgebay commented on a diff in the pull request:
https://github.com/apache/tinkerpop/pull/704#discussion_r137214097
--- Diff: gremlin-dotnet/src/Gremlin.Net/Driver/ConnectionPool.cs ---
@@ -74,6 +85,36 @@ private void AddConnection(Connection connection)
}
}
+ private void ConsiderUnavailable()
+ {
+ CloseAndRemoveAllConnections();
+ }
+
+ private void CloseAndRemoveAllConnections()
+ {
+ lock (_connectionsLock)
+ {
+ TeardownAsync().WaitUnwrap();
+ RemoveAllConnections();
+ }
+ }
+
+ private void RemoveAllConnections()
+ {
+ while (!_connections.IsEmpty)
+ {
+ _connections.TryTake(out var connection);
+ connection.Dispose();
+ }
+ }
+
+ private async Task TeardownAsync()
+ {
+ var closeTasks = new List<Task>(_connections.Count);
--- End diff --
The list isn't necessary, you can use the `Task.WhenAll(IEnumerable<Task>)`
overload instead: `Task.WhenAll(_connections.Select(c => c.CloseAsync()))`
---