We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
我看到源码中 RandomSelectStrategy#randomGet (在这)
private Connection randomGet(List<Connection> connections) { if (null == connections || connections.isEmpty()) { return null; } int size = connections.size(); int tries = 0; Connection result = null; while ((result == null || !result.isFine()) && tries++ < MAX_TIMES) { result = connections.get(this.random.nextInt(size)); } if (result != null && !result.isFine()) { result = null; } return result; }
如果 connections 有部分 !conn.isFine() 而在 MAX_TIMES 此后仍然没有找到 可用的连接就会返回null 吗。 为什么不是在筛选出 fine 的连接再 random 出来呢?
!conn.isFine()
The text was updated successfully, but these errors were encountered:
考虑!conn.isFine() 为小概率事件,每次都要塞选一遍复杂度变成o(n)了
Sorry, something went wrong.
No branches or pull requests
我看到源码中 RandomSelectStrategy#randomGet (在这)
如果 connections 有部分
!conn.isFine()
而在 MAX_TIMES 此后仍然没有找到 可用的连接就会返回null 吗。为什么不是在筛选出 fine 的连接再 random 出来呢?
The text was updated successfully, but these errors were encountered: