diff options
author | monster <monster@ydb.tech> | 2022-07-07 14:41:37 +0300 |
---|---|---|
committer | monster <monster@ydb.tech> | 2022-07-07 14:41:37 +0300 |
commit | 06e5c21a835c0e923506c4ff27929f34e00761c2 (patch) | |
tree | 75efcbc6854ef9bd476eb8bf00cc5c900da436a2 /library/cpp/neh/utils.h | |
parent | 03f024c4412e3aa613bb543cf1660176320ba8f4 (diff) | |
download | ydb-06e5c21a835c0e923506c4ff27929f34e00761c2.tar.gz |
fix ya.make
Diffstat (limited to 'library/cpp/neh/utils.h')
-rw-r--r-- | library/cpp/neh/utils.h | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/library/cpp/neh/utils.h b/library/cpp/neh/utils.h new file mode 100644 index 0000000000..ff1f63c2df --- /dev/null +++ b/library/cpp/neh/utils.h @@ -0,0 +1,39 @@ +#pragma once + +#include <library/cpp/threading/atomic/bool.h> + +#include <util/network/address.h> +#include <util/system/thread.h> +#include <util/generic/cast.h> +#include <library/cpp/deprecated/atomic/atomic.h> + +namespace NNeh { + typedef TAutoPtr<TThread> TThreadRef; + + template <typename T, void (T::*M)()> + static void* HelperMemberFunc(void* arg) { + T* obj = reinterpret_cast<T*>(arg); + (obj->*M)(); + return nullptr; + } + + template <typename T, void (T::*M)()> + static TThreadRef Spawn(T* t) { + TThreadRef thr(new TThread(HelperMemberFunc<T, M>, t)); + + thr->Start(); + + return thr; + } + + size_t RealStackSize(size_t len) noexcept; + + //from rfc3986: + //host = IP-literal / IPv4address / reg-name + //IP-literal = "[" ( IPv6address / IPvFuture ) "]" + TString PrintHostByRfc(const NAddr::IRemoteAddr& addr); + + NAddr::IRemoteAddrPtr GetPeerAddr(SOCKET s); + + using TAtomicBool = NAtomic::TBool; +} |