TCPConnector: Add method to connect to server in parallel. (#6)

This substantially speeds up connection times compared to sequentially
trying to connect to each server in round-robin fashion.
This commit is contained in:
Peter Johnson
2017-08-03 16:45:42 -05:00
committed by GitHub
parent e24db75f08
commit 25c8e873d0
2 changed files with 132 additions and 0 deletions

View File

@@ -26,6 +26,7 @@
#include <memory>
#include "llvm/ArrayRef.h"
#include "tcpsockets/NetworkStream.h"
namespace wpi {
@@ -37,6 +38,9 @@ class TCPConnector {
static std::unique_ptr<NetworkStream> connect(const char* server, int port,
Logger& logger,
int timeout = 0);
static std::unique_ptr<NetworkStream> connect_parallel(
llvm::ArrayRef<std::pair<const char*, int>> servers, Logger& logger,
int timeout = 0);
};
} // namespace wpi