aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/BootstrapConnection.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/BootstrapConnection.cpp b/src/BootstrapConnection.cpp
index f74129b..c70fbc9 100644
--- a/src/BootstrapConnection.cpp
+++ b/src/BootstrapConnection.cpp
@@ -54,6 +54,25 @@ namespace sibs
}
}
+ std::future<std::unique_ptr<BootstrapConnection>> BootstrapConnection::create(const Ipv4 &bootstrapAddress)
+ {
+ std::promise<std::unique_ptr<BootstrapConnection>> connectionPromise;
+ std::future<std::unique_ptr<BootstrapConnection>> connectionFuture = connectionPromise.get_future();
+ std::thread([bootstrapAddress](std::promise<std::unique_ptr<BootstrapConnection>> connectionPromise)
+ {
+ try
+ {
+ BootstrapConnection *connection = new BootstrapConnection(bootstrapAddress);
+ connectionPromise.set_value(std::unique_ptr<BootstrapConnection>(connection));
+ }
+ catch(...)
+ {
+ connectionPromise.set_exception(std::current_exception());
+ }
+ }, std::move(connectionPromise)).detach();
+ return connectionFuture;
+ }
+
BootstrapConnection::~BootstrapConnection()
{
alive = false;