diff options
author | bulatman <bulatman@yandex-team.ru> | 2022-02-10 16:45:50 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:50 +0300 |
commit | 6560e4993b14d193f8c879e33a3de5e5eba6e21d (patch) | |
tree | cfd2e2baa05c3196f2caacbb63c32e1df40bc3de /library/cpp/coroutine | |
parent | 7489e4682331202b9c7d863c0898eb83d7b12c2b (diff) | |
download | ydb-6560e4993b14d193f8c879e33a3de5e5eba6e21d.tar.gz |
Restoring authorship annotation for <bulatman@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/coroutine')
-rw-r--r-- | library/cpp/coroutine/engine/helper.cpp | 74 | ||||
-rw-r--r-- | library/cpp/coroutine/engine/helper.h | 30 | ||||
-rw-r--r-- | library/cpp/coroutine/engine/network.cpp | 6 | ||||
-rw-r--r-- | library/cpp/coroutine/engine/ya.make | 4 |
4 files changed, 57 insertions, 57 deletions
diff --git a/library/cpp/coroutine/engine/helper.cpp b/library/cpp/coroutine/engine/helper.cpp index bffe208dc8..c3e36bffb6 100644 --- a/library/cpp/coroutine/engine/helper.cpp +++ b/library/cpp/coroutine/engine/helper.cpp @@ -1,37 +1,37 @@ -#include "helper.h" - -#include "impl.h" -#include "network.h" - -namespace NCoro { - - bool TryConnect(const TString& host, ui16 port, TDuration timeout) { - bool connected = false; - - auto f = [&connected, &host, port, timeout](TCont* c) { - TSocketHolder socket; - TNetworkAddress address(host, port); - connected = (0 == NCoro::ConnectT(c, socket, address, timeout)); - }; - - TContExecutor e(128 * 1024); - e.Create(f, "try_connect"); - e.Execute(); - return connected; - } - - bool WaitUntilConnectable(const TString& host, ui16 port, TDuration timeout) { - const TInstant deadline = timeout.ToDeadLine(); - - for (size_t i = 1; Now() < deadline; ++i) { - const TDuration waitTime = TDuration::MilliSeconds(100) * i * i; - SleepUntil(Min(Now() + waitTime, deadline)); - - if (TryConnect(host, port, waitTime)) { - return true; - } - } - - return false; - } -} +#include "helper.h" + +#include "impl.h" +#include "network.h" + +namespace NCoro { + + bool TryConnect(const TString& host, ui16 port, TDuration timeout) { + bool connected = false; + + auto f = [&connected, &host, port, timeout](TCont* c) { + TSocketHolder socket; + TNetworkAddress address(host, port); + connected = (0 == NCoro::ConnectT(c, socket, address, timeout)); + }; + + TContExecutor e(128 * 1024); + e.Create(f, "try_connect"); + e.Execute(); + return connected; + } + + bool WaitUntilConnectable(const TString& host, ui16 port, TDuration timeout) { + const TInstant deadline = timeout.ToDeadLine(); + + for (size_t i = 1; Now() < deadline; ++i) { + const TDuration waitTime = TDuration::MilliSeconds(100) * i * i; + SleepUntil(Min(Now() + waitTime, deadline)); + + if (TryConnect(host, port, waitTime)) { + return true; + } + } + + return false; + } +} diff --git a/library/cpp/coroutine/engine/helper.h b/library/cpp/coroutine/engine/helper.h index ec2711ba52..0c3e978699 100644 --- a/library/cpp/coroutine/engine/helper.h +++ b/library/cpp/coroutine/engine/helper.h @@ -1,15 +1,15 @@ -#pragma once - -#include <util/generic/string.h> -#include <util/datetime/base.h> - -namespace NCoro { - - // @brief check that address `host`:`port` is connectable - bool TryConnect(const TString& host, ui16 port, TDuration timeout = TDuration::Seconds(1)); - - // @brief waits until address `host`:`port` became connectable, but not more than timeout - // @return true on success, false if timeout exceeded - bool WaitUntilConnectable(const TString& host, ui16 port, TDuration timeout); - -} +#pragma once + +#include <util/generic/string.h> +#include <util/datetime/base.h> + +namespace NCoro { + + // @brief check that address `host`:`port` is connectable + bool TryConnect(const TString& host, ui16 port, TDuration timeout = TDuration::Seconds(1)); + + // @brief waits until address `host`:`port` became connectable, but not more than timeout + // @return true on success, false if timeout exceeded + bool WaitUntilConnectable(const TString& host, ui16 port, TDuration timeout); + +} diff --git a/library/cpp/coroutine/engine/network.cpp b/library/cpp/coroutine/engine/network.cpp index 85b647d210..b5ece3d580 100644 --- a/library/cpp/coroutine/engine/network.cpp +++ b/library/cpp/coroutine/engine/network.cpp @@ -4,7 +4,7 @@ #include <util/generic/scope.h> #include <util/generic/xrange.h> -#include <sys/uio.h> +#include <sys/uio.h> #if defined(_bionic_) # define IOV_MAX 1024 @@ -18,11 +18,11 @@ namespace NCoro { } ssize_t DoReadVector(SOCKET fd, TContIOVector* vec) noexcept { - return readv(fd, (const iovec*) vec->Parts(), Min(IOV_MAX, (int) vec->Count())); + return readv(fd, (const iovec*) vec->Parts(), Min(IOV_MAX, (int) vec->Count())); } ssize_t DoWriteVector(SOCKET fd, TContIOVector* vec) noexcept { - return writev(fd, (const iovec*) vec->Parts(), Min(IOV_MAX, (int) vec->Count())); + return writev(fd, (const iovec*) vec->Parts(), Min(IOV_MAX, (int) vec->Count())); } } diff --git a/library/cpp/coroutine/engine/ya.make b/library/cpp/coroutine/engine/ya.make index 8c20b9afc3..50012181a7 100644 --- a/library/cpp/coroutine/engine/ya.make +++ b/library/cpp/coroutine/engine/ya.make @@ -9,13 +9,13 @@ GENERATE_ENUM_SERIALIZATION(poller.h) GENERATE_ENUM_SERIALIZATION(stack/stack_common.h) PEERDIR( - contrib/libs/libc_compat + contrib/libs/libc_compat library/cpp/containers/intrusive_rb_tree ) SRCS( cont_poller.cpp - helper.cpp + helper.cpp impl.cpp iostatus.cpp network.cpp |