tinkerpop-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jorgebay <...@git.apache.org>
Subject [GitHub] tinkerpop issue #903: Gremlin.Net: Add ConnectionPool min and max sizes TINK...
Date Tue, 11 Sep 2018 09:08:54 GMT
Github user jorgebay commented on the issue:

    https://github.com/apache/tinkerpop/pull/903
  
    Yes, that's the design I was proposing, a minor note:
    
    > Either returns a random `Connection` or returns the least-used `Connection` based
on an in-flight counter on the `Connection` (the latter would be the better solution but is
a bit more complex).
    
    The easiest solution is to round robin through connections, we can use a "modulo counter":
    
    ```csharp
    // Its important to get a reference of the connection array that doesn't change
    // Otherwise the connection length might be modified (see copy-on-write)
    Connection[] connections = GetConnections();
    var connectionIndex = Interlocked.Increment(ref _indexCounter) % connections.Length;
    var connectionToReturn = connections[connectionIndex];
    // TODO: Overflow protection for `_indexCounter`
    ```
    
    Regarding whether to implement both approaches, I think implementing TINKERPOP-1774 with
the current implementation of the pool (dequeuing) comes at a cost of introducing complexity
(in particular `AsyncAutoResetEvent`).
    
    The implementation for this patch is really good, but we can be introducing corner cases
and I think it's not worth the risk. I'd say let's wait for both solutions to be implemented.


---

Mime
View raw message