shuffle.patch 827 B

1234567891011121314151617181920212223242526272829303132
  1. --- contrib/restricted/thrift/thrift/transport/TSocketPool.cpp (index)
  2. +++ contrib/restricted/thrift/thrift/transport/TSocketPool.cpp (working tree)
  3. @@ -21,11 +21,13 @@
  4. #include <algorithm>
  5. #include <iostream>
  6. +#if __cplusplus >= 201703L
  7. +#include <random>
  8. +#endif
  9. #include <thrift/transport/TSocketPool.h>
  10. using std::pair;
  11. -using std::random_shuffle;
  12. using std::string;
  13. using std::vector;
  14. @@ -189,7 +191,13 @@ void TSocketPool::open() {
  15. }
  16. if (randomize_ && numServers > 1) {
  17. - random_shuffle(servers_.begin(), servers_.end());
  18. +#if __cplusplus >= 201703L
  19. + std::random_device rng;
  20. + std::mt19937 urng(rng());
  21. + std::shuffle(servers_.begin(), servers_.end(), urng);
  22. +#else
  23. + std::random_shuffle(servers_.begin(), servers_.end());
  24. +#endif
  25. }
  26. for (size_t i = 0; i < numServers; ++i) {