diff options
author | cerevra <cerevra@yandex-team.ru> | 2022-02-10 16:45:58 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:58 +0300 |
commit | bf41dd01f6c920583e9faae7cd55ed25e547e052 (patch) | |
tree | ec7c8c285ffa648a5c5efeff453787a15ab811ac /util | |
parent | e2c3e3004f7cd68441cefcfa4aaccd3d8051c846 (diff) | |
download | ydb-bf41dd01f6c920583e9faae7cd55ed25e547e052.tar.gz |
Restoring authorship annotation for <cerevra@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util')
-rw-r--r-- | util/datetime/base.pxd | 214 | ||||
-rw-r--r-- | util/generic/benchmark/log2/main.cpp | 2 | ||||
-rw-r--r-- | util/generic/benchmark/log2/ya.make | 2 | ||||
-rw-r--r-- | util/generic/ptr.h | 8 | ||||
-rw-r--r-- | util/generic/strbase.h | 142 | ||||
-rw-r--r-- | util/generic/string.h | 18 | ||||
-rw-r--r-- | util/generic/string_transparent_hash_ut.cpp | 2 | ||||
-rw-r--r-- | util/generic/string_ut.h | 84 | ||||
-rw-r--r-- | util/generic/ut/ya.make | 2 | ||||
-rw-r--r-- | util/network/socket.cpp | 90 | ||||
-rw-r--r-- | util/network/socket.h | 6 | ||||
-rw-r--r-- | util/network/socket_ut.cpp | 70 | ||||
-rw-r--r-- | util/stream/buffered.cpp | 18 | ||||
-rw-r--r-- | util/string/ascii.h | 12 | ||||
-rw-r--r-- | util/system/fasttime.cpp | 2 | ||||
-rw-r--r-- | util/system/madvise.cpp | 170 | ||||
-rw-r--r-- | util/system/madvise.h | 30 | ||||
-rw-r--r-- | util/system/thread.cpp | 30 | ||||
-rw-r--r-- | util/system/thread.h | 92 | ||||
-rw-r--r-- | util/system/thread_ut.cpp | 94 | ||||
-rw-r--r-- | util/system/yassert.cpp | 10 |
21 files changed, 549 insertions, 549 deletions
diff --git a/util/datetime/base.pxd b/util/datetime/base.pxd index 1d863b1bd8..71ce555f17 100644 --- a/util/datetime/base.pxd +++ b/util/datetime/base.pxd @@ -1,81 +1,81 @@ -from libc.stdint cimport uint32_t -from libc.stdint cimport uint64_t -from libcpp cimport bool as bool_t -from posix.types cimport time_t - +from libc.stdint cimport uint32_t +from libc.stdint cimport uint64_t +from libcpp cimport bool as bool_t +from posix.types cimport time_t + from util.generic.string cimport TString, TStringBuf - - -cdef extern from "<util/datetime/base.h>" nogil: - - cdef cppclass TTimeBase: - TTimeBase() - TTimeBase(uint64_t) - - uint64_t GetValue() - double SecondsFloat() - uint64_t MicroSeconds() - uint64_t MilliSeconds() - uint64_t Seconds() - uint64_t Minutes() - uint64_t Hours() - uint64_t Days() - uint64_t NanoSeconds() - uint32_t MicroSecondsOfSecond() - uint32_t MilliSecondsOfSecond() - uint32_t NanoSecondsOfSecond() - - - cdef cppclass TInstant(TTimeBase): - TInstant() - TInstant(uint64_t) - - @staticmethod - TInstant Now() except + - @staticmethod - TInstant Max() - @staticmethod - TInstant Zero() - @staticmethod - TInstant MicroSeconds(uint64_t) - @staticmethod - TInstant MilliSeconds(uint64_t) - @staticmethod - TInstant Seconds(uint64_t) - @staticmethod - TInstant Minutes(uint64_t) - @staticmethod - TInstant Hours(uint64_t) - @staticmethod - TInstant Days(uint64_t) - - time_t TimeT() - - TString ToString() except + - TString ToStringUpToSeconds() except + - TString ToStringLocal() except + - TString ToStringLocalUpToSeconds() except + - TString FormatLocalTime(const char*) - TString FormatGmTime(const char* format) - - @staticmethod - TInstant ParseIso8601(const TStringBuf) except + - @staticmethod - TInstant ParseRfc822(const TStringBuf) except + - @staticmethod - TInstant ParseHttp(const TStringBuf) except + - @staticmethod - TInstant ParseX509Validity(const TStringBuf) except + - - @staticmethod - bool_t TryParseIso8601(const TStringBuf, TInstant&) except + - @staticmethod - bool_t TryParseRfc822(const TStringBuf, TInstant&) except + - @staticmethod - bool_t TryParseHttp(const TStringBuf, TInstant&) except + - @staticmethod - bool_t TryParseX509(const TStringBuf, TInstant&) except + - + + +cdef extern from "<util/datetime/base.h>" nogil: + + cdef cppclass TTimeBase: + TTimeBase() + TTimeBase(uint64_t) + + uint64_t GetValue() + double SecondsFloat() + uint64_t MicroSeconds() + uint64_t MilliSeconds() + uint64_t Seconds() + uint64_t Minutes() + uint64_t Hours() + uint64_t Days() + uint64_t NanoSeconds() + uint32_t MicroSecondsOfSecond() + uint32_t MilliSecondsOfSecond() + uint32_t NanoSecondsOfSecond() + + + cdef cppclass TInstant(TTimeBase): + TInstant() + TInstant(uint64_t) + + @staticmethod + TInstant Now() except + + @staticmethod + TInstant Max() + @staticmethod + TInstant Zero() + @staticmethod + TInstant MicroSeconds(uint64_t) + @staticmethod + TInstant MilliSeconds(uint64_t) + @staticmethod + TInstant Seconds(uint64_t) + @staticmethod + TInstant Minutes(uint64_t) + @staticmethod + TInstant Hours(uint64_t) + @staticmethod + TInstant Days(uint64_t) + + time_t TimeT() + + TString ToString() except + + TString ToStringUpToSeconds() except + + TString ToStringLocal() except + + TString ToStringLocalUpToSeconds() except + + TString FormatLocalTime(const char*) + TString FormatGmTime(const char* format) + + @staticmethod + TInstant ParseIso8601(const TStringBuf) except + + @staticmethod + TInstant ParseRfc822(const TStringBuf) except + + @staticmethod + TInstant ParseHttp(const TStringBuf) except + + @staticmethod + TInstant ParseX509Validity(const TStringBuf) except + + + @staticmethod + bool_t TryParseIso8601(const TStringBuf, TInstant&) except + + @staticmethod + bool_t TryParseRfc822(const TStringBuf, TInstant&) except + + @staticmethod + bool_t TryParseHttp(const TStringBuf, TInstant&) except + + @staticmethod + bool_t TryParseX509(const TStringBuf, TInstant&) except + + @staticmethod TInstant ParseIso8601Deprecated(const TStringBuf) except + @staticmethod @@ -84,7 +84,7 @@ cdef extern from "<util/datetime/base.h>" nogil: TInstant ParseHttpDeprecated(const TStringBuf) except + @staticmethod TInstant ParseX509ValidityDeprecated(const TStringBuf) except + - + @staticmethod bool_t TryParseIso8601Deprecated(const TStringBuf, TInstant&) except + @staticmethod @@ -95,32 +95,32 @@ cdef extern from "<util/datetime/base.h>" nogil: bool_t TryParseX509Deprecated(const TStringBuf, TInstant&) except + - cdef cppclass TDuration(TTimeBase): - TDuration() - TDuration(uint64_t) - - @staticmethod - TDuration MicroSeconds(uint64_t) - - TInstant ToDeadLine() except + - TInstant ToDeadLine(TInstant) except + - - @staticmethod - TDuration Max() - @staticmethod - TDuration Zero() - @staticmethod - TDuration Seconds(uint64_t) - @staticmethod - TDuration Minutes(uint64_t) - @staticmethod - TDuration Hours(uint64_t) - @staticmethod - TDuration Days(uint64_t) - - @staticmethod - TDuration Parse(const TStringBuf) - @staticmethod - bool_t TryParse(const TStringBuf, TDuration&) - - TString ToString() except + + cdef cppclass TDuration(TTimeBase): + TDuration() + TDuration(uint64_t) + + @staticmethod + TDuration MicroSeconds(uint64_t) + + TInstant ToDeadLine() except + + TInstant ToDeadLine(TInstant) except + + + @staticmethod + TDuration Max() + @staticmethod + TDuration Zero() + @staticmethod + TDuration Seconds(uint64_t) + @staticmethod + TDuration Minutes(uint64_t) + @staticmethod + TDuration Hours(uint64_t) + @staticmethod + TDuration Days(uint64_t) + + @staticmethod + TDuration Parse(const TStringBuf) + @staticmethod + bool_t TryParse(const TStringBuf, TDuration&) + + TString ToString() except + diff --git a/util/generic/benchmark/log2/main.cpp b/util/generic/benchmark/log2/main.cpp index 969f09a309..c670f24adf 100644 --- a/util/generic/benchmark/log2/main.cpp +++ b/util/generic/benchmark/log2/main.cpp @@ -1,6 +1,6 @@ #include <library/cpp/testing/benchmark/bench.h> -#include <library/cpp/fast_log/fast_log.h> +#include <library/cpp/fast_log/fast_log.h> #include <util/generic/singleton.h> #include <util/generic/vector.h> diff --git a/util/generic/benchmark/log2/ya.make b/util/generic/benchmark/log2/ya.make index 45d751909e..3a5d702240 100644 --- a/util/generic/benchmark/log2/ya.make +++ b/util/generic/benchmark/log2/ya.make @@ -11,7 +11,7 @@ SRCS( ) PEERDIR( - library/cpp/fast_log + library/cpp/fast_log ) END() diff --git a/util/generic/ptr.h b/util/generic/ptr.h index 19db0e3ec5..acd7949767 100644 --- a/util/generic/ptr.h +++ b/util/generic/ptr.h @@ -686,10 +686,10 @@ public: TIntrusiveConstPtr(nullptr).Swap(*this); } - inline long RefCount() const noexcept { - return T_ ? Ops::RefCount(T_) : 0; - } - + inline long RefCount() const noexcept { + return T_ ? Ops::RefCount(T_) : 0; + } + #ifdef __cpp_impl_three_way_comparison template <class Other> inline bool operator==(const Other& p) const noexcept { diff --git a/util/generic/strbase.h b/util/generic/strbase.h index ab39fc7537..2f74e8d898 100644 --- a/util/generic/strbase.h +++ b/util/generic/strbase.h @@ -51,61 +51,61 @@ public: using const_iterator = const TCharType*; using const_reference = const TCharType&; - template <typename TBase> - struct TReverseIteratorBase { - constexpr TReverseIteratorBase() noexcept = default; - explicit constexpr TReverseIteratorBase(TBase p) - : P_(p) - { - } - - TReverseIteratorBase operator++() noexcept { - --P_; - return *this; - } - - TReverseIteratorBase operator++(int) noexcept { - TReverseIteratorBase old(*this); - --P_; - return old; - } - - TReverseIteratorBase& operator--() noexcept { - ++P_; - return *this; - } - - TReverseIteratorBase operator--(int) noexcept { - TReverseIteratorBase old(*this); - ++P_; - return old; - } - - constexpr auto operator*() const noexcept -> std::remove_pointer_t<TBase>& { - return *TBase(*this); - } - - explicit constexpr operator TBase() const noexcept { - return TBase(P_ - 1); - } - - constexpr auto operator-(const TReverseIteratorBase o) const noexcept { - return o.P_ - P_; - } - - constexpr bool operator==(const TReverseIteratorBase o) const noexcept { - return P_ == o.P_; - } - - constexpr bool operator!=(const TReverseIteratorBase o) const noexcept { - return !(*this == o); - } - - private: - TBase P_ = nullptr; - }; - using const_reverse_iterator = TReverseIteratorBase<const_iterator>; - + template <typename TBase> + struct TReverseIteratorBase { + constexpr TReverseIteratorBase() noexcept = default; + explicit constexpr TReverseIteratorBase(TBase p) + : P_(p) + { + } + + TReverseIteratorBase operator++() noexcept { + --P_; + return *this; + } + + TReverseIteratorBase operator++(int) noexcept { + TReverseIteratorBase old(*this); + --P_; + return old; + } + + TReverseIteratorBase& operator--() noexcept { + ++P_; + return *this; + } + + TReverseIteratorBase operator--(int) noexcept { + TReverseIteratorBase old(*this); + ++P_; + return old; + } + + constexpr auto operator*() const noexcept -> std::remove_pointer_t<TBase>& { + return *TBase(*this); + } + + explicit constexpr operator TBase() const noexcept { + return TBase(P_ - 1); + } + + constexpr auto operator-(const TReverseIteratorBase o) const noexcept { + return o.P_ - P_; + } + + constexpr bool operator==(const TReverseIteratorBase o) const noexcept { + return P_ == o.P_; + } + + constexpr bool operator!=(const TReverseIteratorBase o) const noexcept { + return !(*this == o); + } + + private: + TBase P_ = nullptr; + }; + using const_reverse_iterator = TReverseIteratorBase<const_iterator>; + static constexpr size_t StrLen(const TCharType* s) noexcept { if (Y_LIKELY(s)) { return TTraits::length(s); @@ -151,22 +151,22 @@ public: return end(); } - inline const_reverse_iterator rbegin() const noexcept { - return const_reverse_iterator(Ptr() + size()); - } - - inline const_reverse_iterator rend() const noexcept { - return const_reverse_iterator(Ptr()); - } - - inline const_reverse_iterator crbegin() const noexcept { - return rbegin(); - } - - inline const_reverse_iterator crend() const noexcept { - return rend(); - } - + inline const_reverse_iterator rbegin() const noexcept { + return const_reverse_iterator(Ptr() + size()); + } + + inline const_reverse_iterator rend() const noexcept { + return const_reverse_iterator(Ptr()); + } + + inline const_reverse_iterator crbegin() const noexcept { + return rbegin(); + } + + inline const_reverse_iterator crend() const noexcept { + return rend(); + } + inline TCharType back() const noexcept { Y_ASSERT(!this->empty()); return Ptr()[Len() - 1]; diff --git a/util/generic/string.h b/util/generic/string.h index 8cd8aa6917..aa51327b6f 100644 --- a/util/generic/string.h +++ b/util/generic/string.h @@ -315,22 +315,22 @@ public: return &*MutRef().end(); } - reverse_iterator rbegin() { + reverse_iterator rbegin() { return reverse_iterator(vend()); - } - - reverse_iterator rend() { + } + + reverse_iterator rend() { return reverse_iterator(begin()); - } - + } + using TBase::begin; //!< const_iterator TStringBase::begin() const using TBase::cbegin; //!< const_iterator TStringBase::cbegin() const using TBase::cend; //!< const_iterator TStringBase::cend() const - using TBase::crbegin; //!< const_reverse_iterator TStringBase::crbegin() const - using TBase::crend; //!< const_reverse_iterator TStringBase::crend() const + using TBase::crbegin; //!< const_reverse_iterator TStringBase::crbegin() const + using TBase::crend; //!< const_reverse_iterator TStringBase::crend() const using TBase::end; //!< const_iterator TStringBase::end() const using TBase::rbegin; //!< const_reverse_iterator TStringBase::rbegin() const - using TBase::rend; //!< const_reverse_iterator TStringBase::rend() const + using TBase::rend; //!< const_reverse_iterator TStringBase::rend() const inline size_t capacity() const noexcept { #ifdef TSTRING_IS_STD_STRING diff --git a/util/generic/string_transparent_hash_ut.cpp b/util/generic/string_transparent_hash_ut.cpp index b87fa2843e..0e0dbf8546 100644 --- a/util/generic/string_transparent_hash_ut.cpp +++ b/util/generic/string_transparent_hash_ut.cpp @@ -3,7 +3,7 @@ #include "strbuf.h" #include <library/cpp/testing/unittest/registar.h> -#include <library/cpp/containers/absl_flat_hash/flat_hash_set.h> +#include <library/cpp/containers/absl_flat_hash/flat_hash_set.h> #include <util/str_stl.h> diff --git a/util/generic/string_ut.h b/util/generic/string_ut.h index 44bb10bdeb..b4768cc633 100644 --- a/util/generic/string_ut.h +++ b/util/generic/string_ut.h @@ -1074,83 +1074,83 @@ public: UNIT_ASSERT_VALUES_EQUAL(constStr.front(), (ui8)'f'); UNIT_ASSERT_VALUES_EQUAL(str.front(), (ui8)'r'); } - + void TestIterators() { - const char_type chars[] = {'f', 'o', 0}; - - TStringType str = chars; - const TStringType constStr = str; - - typename TStringType::const_iterator itBegin = str.begin(); - typename TStringType::const_iterator itEnd = str.end(); - typename TStringType::const_iterator citBegin = constStr.begin(); - typename TStringType::const_iterator citEnd = constStr.end(); - + const char_type chars[] = {'f', 'o', 0}; + + TStringType str = chars; + const TStringType constStr = str; + + typename TStringType::const_iterator itBegin = str.begin(); + typename TStringType::const_iterator itEnd = str.end(); + typename TStringType::const_iterator citBegin = constStr.begin(); + typename TStringType::const_iterator citEnd = constStr.end(); + UNIT_ASSERT_VALUES_EQUAL(*itBegin, (ui8)'f'); UNIT_ASSERT_VALUES_EQUAL(*citBegin, (ui8)'f'); - - str.front() = 'r'; + + str.front() = 'r'; UNIT_ASSERT_VALUES_EQUAL(*itBegin, (ui8)'r'); UNIT_ASSERT_VALUES_EQUAL(*citBegin, (ui8)'f'); - - UNIT_ASSERT_VALUES_EQUAL(2, itEnd - itBegin); - UNIT_ASSERT_VALUES_EQUAL(2, citEnd - citBegin); - + + UNIT_ASSERT_VALUES_EQUAL(2, itEnd - itBegin); + UNIT_ASSERT_VALUES_EQUAL(2, citEnd - citBegin); + UNIT_ASSERT_VALUES_EQUAL(*(++itBegin), (ui8)'o'); UNIT_ASSERT_VALUES_EQUAL(*(++citBegin), (ui8)'o'); - + UNIT_ASSERT_VALUES_EQUAL(*(--itBegin), (ui8)'r'); UNIT_ASSERT_VALUES_EQUAL(*(--citBegin), (ui8)'f'); - + UNIT_ASSERT_VALUES_EQUAL(*(itBegin++), (ui8)'r'); UNIT_ASSERT_VALUES_EQUAL(*(citBegin++), (ui8)'f'); UNIT_ASSERT_VALUES_EQUAL(*itBegin, (ui8)'o'); UNIT_ASSERT_VALUES_EQUAL(*citBegin, (ui8)'o'); - + UNIT_ASSERT_VALUES_EQUAL(*(itBegin--), (ui8)'o'); UNIT_ASSERT_VALUES_EQUAL(*(citBegin--), (ui8)'o'); UNIT_ASSERT_VALUES_EQUAL(*itBegin, (ui8)'r'); UNIT_ASSERT_VALUES_EQUAL(*citBegin, (ui8)'f'); - } - + } + void TestReverseIterators() { - const char_type chars[] = {'f', 'o', 0}; - - TStringType str = chars; - const TStringType constStr = str; - - typename TStringType::reverse_iterator ritBegin = str.rbegin(); - typename TStringType::reverse_iterator ritEnd = str.rend(); - typename TStringType::const_reverse_iterator critBegin = constStr.rbegin(); - typename TStringType::const_reverse_iterator critEnd = constStr.rend(); - + const char_type chars[] = {'f', 'o', 0}; + + TStringType str = chars; + const TStringType constStr = str; + + typename TStringType::reverse_iterator ritBegin = str.rbegin(); + typename TStringType::reverse_iterator ritEnd = str.rend(); + typename TStringType::const_reverse_iterator critBegin = constStr.rbegin(); + typename TStringType::const_reverse_iterator critEnd = constStr.rend(); + UNIT_ASSERT_VALUES_EQUAL(*ritBegin, (ui8)'o'); UNIT_ASSERT_VALUES_EQUAL(*critBegin, (ui8)'o'); - + str.back() = (ui8)'r'; UNIT_ASSERT_VALUES_EQUAL(*ritBegin, (ui8)'r'); UNIT_ASSERT_VALUES_EQUAL(*critBegin, (ui8)'o'); - - UNIT_ASSERT_VALUES_EQUAL(2, ritEnd - ritBegin); - UNIT_ASSERT_VALUES_EQUAL(2, critEnd - critBegin); - + + UNIT_ASSERT_VALUES_EQUAL(2, ritEnd - ritBegin); + UNIT_ASSERT_VALUES_EQUAL(2, critEnd - critBegin); + UNIT_ASSERT_VALUES_EQUAL(*(++ritBegin), (ui8)'f'); UNIT_ASSERT_VALUES_EQUAL(*(++critBegin), (ui8)'f'); - + UNIT_ASSERT_VALUES_EQUAL(*(--ritBegin), (ui8)'r'); UNIT_ASSERT_VALUES_EQUAL(*(--critBegin), (ui8)'o'); - + UNIT_ASSERT_VALUES_EQUAL(*(ritBegin++), (ui8)'r'); UNIT_ASSERT_VALUES_EQUAL(*(critBegin++), (ui8)'o'); UNIT_ASSERT_VALUES_EQUAL(*ritBegin, (ui8)'f'); UNIT_ASSERT_VALUES_EQUAL(*critBegin, (ui8)'f'); - + UNIT_ASSERT_VALUES_EQUAL(*(ritBegin--), (ui8)'f'); UNIT_ASSERT_VALUES_EQUAL(*(critBegin--), (ui8)'f'); UNIT_ASSERT_VALUES_EQUAL(*ritBegin, (ui8)'r'); UNIT_ASSERT_VALUES_EQUAL(*critBegin, (ui8)'o'); - + *ritBegin = (ui8)'e'; UNIT_ASSERT_VALUES_EQUAL(*ritBegin, (ui8)'e'); - } + } }; diff --git a/util/generic/ut/ya.make b/util/generic/ut/ya.make index 6eaf24cc5f..3f451731a0 100644 --- a/util/generic/ut/ya.make +++ b/util/generic/ut/ya.make @@ -62,7 +62,7 @@ IF (NOT OS_IOS AND NOT ARCH_PPC64LE) # Abseil fails to build (with linkage error) on ios and with compilation error on PowerPC # (somewhere in unscaledcycleclock.cc). PEERDIR( - library/cpp/containers/absl_flat_hash + library/cpp/containers/absl_flat_hash ) SRCS( diff --git a/util/network/socket.cpp b/util/network/socket.cpp index 4f6e804346..6a7d3a9d28 100644 --- a/util/network/socket.cpp +++ b/util/network/socket.cpp @@ -490,44 +490,44 @@ void SetTcpFastOpen(SOCKET s, int qlen) { #endif } -static bool IsBlocked(int lasterr) noexcept { - return lasterr == EAGAIN || lasterr == EWOULDBLOCK; -} - -struct TUnblockingGuard { - SOCKET S_; - - TUnblockingGuard(SOCKET s) - : S_(s) - { - SetNonBlock(S_, true); - } - - ~TUnblockingGuard() { - SetNonBlock(S_, false); - } -}; - -static int MsgPeek(SOCKET s) { - int flags = MSG_PEEK; - +static bool IsBlocked(int lasterr) noexcept { + return lasterr == EAGAIN || lasterr == EWOULDBLOCK; +} + +struct TUnblockingGuard { + SOCKET S_; + + TUnblockingGuard(SOCKET s) + : S_(s) + { + SetNonBlock(S_, true); + } + + ~TUnblockingGuard() { + SetNonBlock(S_, false); + } +}; + +static int MsgPeek(SOCKET s) { + int flags = MSG_PEEK; + #if defined(_win_) - TUnblockingGuard unblocker(s); - Y_UNUSED(unblocker); -#else - flags |= MSG_DONTWAIT; -#endif - - char c; - return recv(s, &c, 1, flags); -} - -bool IsNotSocketClosedByOtherSide(SOCKET s) { + TUnblockingGuard unblocker(s); + Y_UNUSED(unblocker); +#else + flags |= MSG_DONTWAIT; +#endif + + char c; + return recv(s, &c, 1, flags); +} + +bool IsNotSocketClosedByOtherSide(SOCKET s) { return HasSocketDataToRead(s) != ESocketReadStatus::SocketClosed; } ESocketReadStatus HasSocketDataToRead(SOCKET s) { - const int r = MsgPeek(s); + const int r = MsgPeek(s); if (r == -1 && IsBlocked(LastSystemError())) { return ESocketReadStatus::NoData; } @@ -535,9 +535,9 @@ ESocketReadStatus HasSocketDataToRead(SOCKET s) { return ESocketReadStatus::HasData; } return ESocketReadStatus::SocketClosed; -} - -#if defined(_win_) +} + +#if defined(_win_) static ssize_t DoSendMsg(SOCKET sock, const struct iovec* iov, int iovcnt) { return writev(sock, iov, iovcnt); } @@ -1097,15 +1097,15 @@ TNetworkResolutionError::TNetworkResolutionError(int error) { #else errMsg = gai_strerror(error); #endif - (*this) << errMsg << "(" << error; - -#if defined(_unix_) - if (error == EAI_SYSTEM) { - (*this) << "; errno=" << LastSystemError(); - } -#endif - - (*this) << "): "; + (*this) << errMsg << "(" << error; + +#if defined(_unix_) + if (error == EAI_SYSTEM) { + (*this) << "; errno=" << LastSystemError(); + } +#endif + + (*this) << "): "; } #if defined(_unix_) diff --git a/util/network/socket.h b/util/network/socket.h index 40c8648b40..f5c3279e5e 100644 --- a/util/network/socket.h +++ b/util/network/socket.h @@ -120,14 +120,14 @@ void SetSocketPriority(SOCKET s, int priority); void SetTcpFastOpen(SOCKET s, int qlen); /** * Deprecated, consider using HasSocketDataToRead instead. - **/ -bool IsNotSocketClosedByOtherSide(SOCKET s); + **/ +bool IsNotSocketClosedByOtherSide(SOCKET s); enum class ESocketReadStatus { HasData, NoData, SocketClosed }; -/** +/** * Useful for keep-alive connections. **/ ESocketReadStatus HasSocketDataToRead(SOCKET s); diff --git a/util/network/socket_ut.cpp b/util/network/socket_ut.cpp index 6b20e11f70..00f27fce4b 100644 --- a/util/network/socket_ut.cpp +++ b/util/network/socket_ut.cpp @@ -22,7 +22,7 @@ class TSockTest: public TTestBase { UNIT_TEST_EXCEPTION(TestConnectionRefused, yexception); #endif UNIT_TEST(TestNetworkResolutionError); - UNIT_TEST(TestNetworkResolutionErrorMessage); + UNIT_TEST(TestNetworkResolutionErrorMessage); UNIT_TEST(TestBrokenPipe); UNIT_TEST(TestClose); UNIT_TEST(TestReusePortAvailCheck); @@ -33,7 +33,7 @@ public: void TestTimeout(); void TestConnectionRefused(); void TestNetworkResolutionError(); - void TestNetworkResolutionErrorMessage(); + void TestNetworkResolutionErrorMessage(); void TestBrokenPipe(); void TestClose(); void TestReusePortAvailCheck(); @@ -92,42 +92,42 @@ void TSockTest::TestNetworkResolutionError() { } } -void TSockTest::TestNetworkResolutionErrorMessage() { -#ifdef _unix_ - auto str = [](int code) -> TString { - return TNetworkResolutionError(code).what(); - }; - - auto expected = [](int code) -> TString { - return gai_strerror(code); - }; - - struct TErrnoGuard { - TErrnoGuard() +void TSockTest::TestNetworkResolutionErrorMessage() { +#ifdef _unix_ + auto str = [](int code) -> TString { + return TNetworkResolutionError(code).what(); + }; + + auto expected = [](int code) -> TString { + return gai_strerror(code); + }; + + struct TErrnoGuard { + TErrnoGuard() : PrevValue_(errno) - { - } - - ~TErrnoGuard() { + { + } + + ~TErrnoGuard() { errno = PrevValue_; - } - - private: + } + + private: int PrevValue_; - } g; - - UNIT_ASSERT_VALUES_EQUAL(expected(0) + "(0): ", str(0)); - UNIT_ASSERT_VALUES_EQUAL(expected(-9) + "(-9): ", str(-9)); - - errno = 0; - UNIT_ASSERT_VALUES_EQUAL(expected(EAI_SYSTEM) + "(" + IntToString<10>(EAI_SYSTEM) + "; errno=0): ", - str(EAI_SYSTEM)); - errno = 110; - UNIT_ASSERT_VALUES_EQUAL(expected(EAI_SYSTEM) + "(" + IntToString<10>(EAI_SYSTEM) + "; errno=110): ", - str(EAI_SYSTEM)); -#endif -} - + } g; + + UNIT_ASSERT_VALUES_EQUAL(expected(0) + "(0): ", str(0)); + UNIT_ASSERT_VALUES_EQUAL(expected(-9) + "(-9): ", str(-9)); + + errno = 0; + UNIT_ASSERT_VALUES_EQUAL(expected(EAI_SYSTEM) + "(" + IntToString<10>(EAI_SYSTEM) + "; errno=0): ", + str(EAI_SYSTEM)); + errno = 110; + UNIT_ASSERT_VALUES_EQUAL(expected(EAI_SYSTEM) + "(" + IntToString<10>(EAI_SYSTEM) + "; errno=110): ", + str(EAI_SYSTEM)); +#endif +} + class TTempEnableSigPipe { public: TTempEnableSigPipe() { diff --git a/util/stream/buffered.cpp b/util/stream/buffered.cpp index a00e592e1c..570dbfb7bb 100644 --- a/util/stream/buffered.cpp +++ b/util/stream/buffered.cpp @@ -63,8 +63,8 @@ public: } inline size_t ReadTo(TString& st, char to) { - st.clear(); - + st.clear(); + TString s_tmp; size_t ret = 0; @@ -81,14 +81,14 @@ public: } const size_t a_len(MemInput_.Avail()); - size_t s_len = 0; - if (st.empty()) { - ret += MemInput_.ReadTo(st, to); - s_len = st.length(); + size_t s_len = 0; + if (st.empty()) { + ret += MemInput_.ReadTo(st, to); + s_len = st.length(); } else { - ret += MemInput_.ReadTo(s_tmp, to); - s_len = s_tmp.length(); - st.append(s_tmp); + ret += MemInput_.ReadTo(s_tmp, to); + s_len = s_tmp.length(); + st.append(s_tmp); } if (s_len != a_len) { diff --git a/util/string/ascii.h b/util/string/ascii.h index 10344384d3..aa2a4a3426 100644 --- a/util/string/ascii.h +++ b/util/string/ascii.h @@ -159,7 +159,7 @@ inline ::NPrivate::TDereferenced<T> AsciiToUpper(T c) noexcept { /** * ASCII case-insensitive string comparison (for proper UTF8 strings - * case-insensitive comparison consider using @c library/cpp/charset). + * case-insensitive comparison consider using @c library/cpp/charset). * * BUGS: Currently will NOT work properly with strings that contain * 0-terminator character inside. See IGNIETFERRO-1641 for details. @@ -172,7 +172,7 @@ static inline bool AsciiEqualsIgnoreCase(const char* s1, const char* s2) noexcep /** * ASCII case-insensitive string comparison (for proper UTF8 strings - * case-insensitive comparison consider using @c library/cpp/charset). + * case-insensitive comparison consider using @c library/cpp/charset). * * BUGS: Currently will NOT work properly with strings that contain * 0-terminator character inside. See IGNIETFERRO-1641 for details. @@ -185,7 +185,7 @@ static inline bool AsciiEqualsIgnoreCase(const TStringBuf s1, const TStringBuf s /** * ASCII case-insensitive string comparison (for proper UTF8 strings - * case-insensitive comparison consider using @c library/cpp/charset). + * case-insensitive comparison consider using @c library/cpp/charset). * * BUGS: Currently will NOT work properly with strings that contain * 0-terminator character inside. See IGNIETFERRO-1641 for details. @@ -200,7 +200,7 @@ static inline int AsciiCompareIgnoreCase(const char* s1, const char* s2) noexcep /** * ASCII case-insensitive string comparison (for proper UTF8 strings - * case-insensitive comparison consider using @c library/cpp/charset). + * case-insensitive comparison consider using @c library/cpp/charset). * * BUGS: Currently will NOT work properly with strings that contain * 0-terminator character inside. See IGNIETFERRO-1641 for details. @@ -228,7 +228,7 @@ static inline bool AsciiHasPrefix(const TStringBuf s1, const TStringBuf s2) noex /** * ASCII case-insensitive string comparison (for proper UTF8 strings - * case-insensitive comparison consider using @c library/cpp/charset). + * case-insensitive comparison consider using @c library/cpp/charset). * * @return true iff @c s2 are case-insensitively prefix of @c s1. */ @@ -238,7 +238,7 @@ static inline bool AsciiHasPrefixIgnoreCase(const TStringBuf s1, const TStringBu /** * ASCII case-insensitive string comparison (for proper UTF8 strings - * case-insensitive comparison consider using @c library/cpp/charset). + * case-insensitive comparison consider using @c library/cpp/charset). * * @return true iff @c s2 are case-insensitively suffix of @c s1. */ diff --git a/util/system/fasttime.cpp b/util/system/fasttime.cpp index 057a814f0a..512de42872 100644 --- a/util/system/fasttime.cpp +++ b/util/system/fasttime.cpp @@ -33,7 +33,7 @@ namespace { inline TSymbols() : Func(nullptr) { - // not DEFAULT, cause library/cpp/gettimeofday + // not DEFAULT, cause library/cpp/gettimeofday Func = reinterpret_cast<TFunc>(dlsym(RTLD_NEXT, "gettimeofday")); #if defined(_musl_) diff --git a/util/system/madvise.cpp b/util/system/madvise.cpp index 58c894e3ef..0e7aea280a 100644 --- a/util/system/madvise.cpp +++ b/util/system/madvise.cpp @@ -19,22 +19,22 @@ #ifndef MADV_DODUMP /* This flag is defined in sys/mman.h since Linux 3.4, but currently old libc header is in use \ for capability with Ubuntu 12.04, so we need to define it here manually */ #define MADV_DODUMP 17 /* Undo the effect of an earlier MADV_DONTDUMP */ -#endif - +#endif + namespace { - void Madvise(int flag, const void* cbegin, size_t size) { + void Madvise(int flag, const void* cbegin, size_t size) { static const size_t pageSize = NSystemInfo::GetPageSize(); void* begin = AlignDown(const_cast<void*>(cbegin), pageSize); size = AlignUp(size, pageSize); #if defined(_win_) - if (!VirtualFree((LPVOID)begin, size, flag)) { - TString err(LastSystemErrorText()); - ythrow yexception() << "VirtualFree(" << begin << ", " << size << ", " << flag << ")" - << " returned error: " << err; + if (!VirtualFree((LPVOID)begin, size, flag)) { + TString err(LastSystemErrorText()); + ythrow yexception() << "VirtualFree(" << begin << ", " << size << ", " << flag << ")" + << " returned error: " << err; } #else - if (-1 == madvise(begin, size, flag)) { + if (-1 == madvise(begin, size, flag)) { TString err(LastSystemErrorText()); ythrow yexception() << "madvise(" << begin << ", " << size << ", " << flag << ")" << " returned error: " << err; @@ -44,83 +44,83 @@ namespace { } void MadviseSequentialAccess(const void* begin, size_t size) { -#if !defined(_win_) - Madvise(MADV_SEQUENTIAL, begin, size); -#endif -} - -void MadviseSequentialAccess(TArrayRef<const char> data) { - MadviseSequentialAccess(data.data(), data.size()); -} - -void MadviseSequentialAccess(TArrayRef<const ui8> data) { - MadviseSequentialAccess(data.data(), data.size()); -} - +#if !defined(_win_) + Madvise(MADV_SEQUENTIAL, begin, size); +#endif +} + +void MadviseSequentialAccess(TArrayRef<const char> data) { + MadviseSequentialAccess(data.data(), data.size()); +} + +void MadviseSequentialAccess(TArrayRef<const ui8> data) { + MadviseSequentialAccess(data.data(), data.size()); +} + void MadviseRandomAccess(const void* begin, size_t size) { -#if !defined(_win_) - Madvise(MADV_RANDOM, begin, size); -#endif -} - -void MadviseRandomAccess(TArrayRef<const char> data) { - MadviseRandomAccess(data.data(), data.size()); -} - -void MadviseRandomAccess(TArrayRef<const ui8> data) { - MadviseRandomAccess(data.data(), data.size()); -} - +#if !defined(_win_) + Madvise(MADV_RANDOM, begin, size); +#endif +} + +void MadviseRandomAccess(TArrayRef<const char> data) { + MadviseRandomAccess(data.data(), data.size()); +} + +void MadviseRandomAccess(TArrayRef<const ui8> data) { + MadviseRandomAccess(data.data(), data.size()); +} + void MadviseEvict(const void* begin, size_t size) { -#if defined(_win_) - Madvise(MEM_DECOMMIT, begin, size); -#elif defined(_linux_) || defined(_cygwin_) - Madvise(MADV_DONTNEED, begin, size); -#else // freebsd, osx - Madvise(MADV_FREE, begin, size); -#endif -} - -void MadviseEvict(TArrayRef<const char> data) { - MadviseEvict(data.data(), data.size()); -} - -void MadviseEvict(TArrayRef<const ui8> data) { - MadviseEvict(data.data(), data.size()); -} - +#if defined(_win_) + Madvise(MEM_DECOMMIT, begin, size); +#elif defined(_linux_) || defined(_cygwin_) + Madvise(MADV_DONTNEED, begin, size); +#else // freebsd, osx + Madvise(MADV_FREE, begin, size); +#endif +} + +void MadviseEvict(TArrayRef<const char> data) { + MadviseEvict(data.data(), data.size()); +} + +void MadviseEvict(TArrayRef<const ui8> data) { + MadviseEvict(data.data(), data.size()); +} + void MadviseExcludeFromCoreDump(const void* begin, size_t size) { -#if defined(_darwin_) - // Don't try to call function with flag which doesn't work - // https://st.yandex-team.ru/PASSP-31755#6050bbafc68f501f2c22caab - Y_UNUSED(begin); - Y_UNUSED(size); -#elif !defined(_win_) - Madvise(MADV_DONTDUMP, begin, size); -#endif -} - -void MadviseExcludeFromCoreDump(TArrayRef<const char> data) { - MadviseExcludeFromCoreDump(data.data(), data.size()); -} - -void MadviseExcludeFromCoreDump(TArrayRef<const ui8> data) { - MadviseExcludeFromCoreDump(data.data(), data.size()); -} - -void MadviseIncludeIntoCoreDump(const void* begin, size_t size) { -#if defined(_darwin_) - Y_UNUSED(begin); - Y_UNUSED(size); -#elif !defined(_win_) - Madvise(MADV_DODUMP, begin, size); -#endif -} - -void MadviseIncludeIntoCoreDump(TArrayRef<const char> data) { - MadviseIncludeIntoCoreDump(data.data(), data.size()); -} - -void MadviseIncludeIntoCoreDump(TArrayRef<const ui8> data) { - MadviseIncludeIntoCoreDump(data.data(), data.size()); -} +#if defined(_darwin_) + // Don't try to call function with flag which doesn't work + // https://st.yandex-team.ru/PASSP-31755#6050bbafc68f501f2c22caab + Y_UNUSED(begin); + Y_UNUSED(size); +#elif !defined(_win_) + Madvise(MADV_DONTDUMP, begin, size); +#endif +} + +void MadviseExcludeFromCoreDump(TArrayRef<const char> data) { + MadviseExcludeFromCoreDump(data.data(), data.size()); +} + +void MadviseExcludeFromCoreDump(TArrayRef<const ui8> data) { + MadviseExcludeFromCoreDump(data.data(), data.size()); +} + +void MadviseIncludeIntoCoreDump(const void* begin, size_t size) { +#if defined(_darwin_) + Y_UNUSED(begin); + Y_UNUSED(size); +#elif !defined(_win_) + Madvise(MADV_DODUMP, begin, size); +#endif +} + +void MadviseIncludeIntoCoreDump(TArrayRef<const char> data) { + MadviseIncludeIntoCoreDump(data.data(), data.size()); +} + +void MadviseIncludeIntoCoreDump(TArrayRef<const ui8> data) { + MadviseIncludeIntoCoreDump(data.data(), data.size()); +} diff --git a/util/system/madvise.h b/util/system/madvise.h index 606733152e..d875cce245 100644 --- a/util/system/madvise.h +++ b/util/system/madvise.h @@ -2,29 +2,29 @@ #include "defaults.h" -#include <util/generic/array_ref.h> - +#include <util/generic/array_ref.h> + /// see linux madvise(MADV_SEQUENTIAL) void MadviseSequentialAccess(const void* begin, size_t size); -void MadviseSequentialAccess(TArrayRef<const char> data); -void MadviseSequentialAccess(TArrayRef<const ui8> data); +void MadviseSequentialAccess(TArrayRef<const char> data); +void MadviseSequentialAccess(TArrayRef<const ui8> data); /// see linux madvise(MADV_RANDOM) void MadviseRandomAccess(const void* begin, size_t size); -void MadviseRandomAccess(TArrayRef<const char> data); -void MadviseRandomAccess(TArrayRef<const ui8> data); +void MadviseRandomAccess(TArrayRef<const char> data); +void MadviseRandomAccess(TArrayRef<const ui8> data); /// see linux madvise(MADV_DONTNEED) void MadviseEvict(const void* begin, size_t size); -void MadviseEvict(TArrayRef<const char> data); -void MadviseEvict(TArrayRef<const ui8> data); +void MadviseEvict(TArrayRef<const char> data); +void MadviseEvict(TArrayRef<const ui8> data); /// see linux madvise(MADV_DONTDUMP) void MadviseExcludeFromCoreDump(const void* begin, size_t size); -void MadviseExcludeFromCoreDump(TArrayRef<const char> data); -void MadviseExcludeFromCoreDump(TArrayRef<const ui8> data); - -/// see linux madvise(MADV_DODUMP) -void MadviseIncludeIntoCoreDump(const void* begin, size_t size); -void MadviseIncludeIntoCoreDump(TArrayRef<const char> data); -void MadviseIncludeIntoCoreDump(TArrayRef<const ui8> data); +void MadviseExcludeFromCoreDump(TArrayRef<const char> data); +void MadviseExcludeFromCoreDump(TArrayRef<const ui8> data); + +/// see linux madvise(MADV_DODUMP) +void MadviseIncludeIntoCoreDump(const void* begin, size_t size); +void MadviseIncludeIntoCoreDump(TArrayRef<const char> data); +void MadviseIncludeIntoCoreDump(TArrayRef<const ui8> data); diff --git a/util/system/thread.cpp b/util/system/thread.cpp index 6236746c2d..d529776f49 100644 --- a/util/system/thread.cpp +++ b/util/system/thread.cpp @@ -251,23 +251,23 @@ namespace { class TThread::TImpl: public TThreadBase { public: - inline TImpl(const TParams& params, THolder<TCallableBase> callable = {}) + inline TImpl(const TParams& params, THolder<TCallableBase> callable = {}) : TThreadBase(params) - , Callable_(std::move(callable)) + , Callable_(std::move(callable)) { } inline TId Id() const noexcept { return ThreadIdHashFunction(SystemThreadId()); } - - static THolder<TImpl> Create(THolder<TCallableBase> callable) { - TParams params(TCallableBase::ThreadWorker, callable.Get()); - return MakeHolder<TImpl>(std::move(params), std::move(callable)); - } - -private: - THolder<TCallableBase> Callable_; + + static THolder<TImpl> Create(THolder<TCallableBase> callable) { + TParams params(TCallableBase::ThreadWorker, callable.Get()); + return MakeHolder<TImpl>(std::move(params), std::move(callable)); + } + +private: + THolder<TCallableBase> Callable_; }; TThread::TThread(const TParams& p) @@ -280,11 +280,11 @@ TThread::TThread(TThreadProc threadProc, void* param) { } -TThread::TThread(TPrivateCtor, THolder<TCallableBase> callable) - : Impl_(TImpl::Create(std::move(callable))) -{ -} - +TThread::TThread(TPrivateCtor, THolder<TCallableBase> callable) + : Impl_(TImpl::Create(std::move(callable))) +{ +} + TThread::~TThread() { Join(); } diff --git a/util/system/thread.h b/util/system/thread.h index a6e8abdb5b..588c96985f 100644 --- a/util/system/thread.h +++ b/util/system/thread.h @@ -13,10 +13,10 @@ bool SetHighestThreadPriority(); class TThread { - template <typename Callable> - struct TCallableParams; - struct TPrivateCtor {}; - + template <typename Callable> + struct TCallableParams; + struct TPrivateCtor {}; + public: using TThreadProc = void* (*)(void*); using TId = size_t; @@ -75,23 +75,23 @@ public: TThread(const TParams& params); TThread(TThreadProc threadProc, void* param); - template <typename Callable> - TThread(Callable&& callable) - : TThread(TPrivateCtor{}, + template <typename Callable> + TThread(Callable&& callable) + : TThread(TPrivateCtor{}, MakeHolder<TCallableParams<Callable>>(std::forward<Callable>(callable))) { - } - - TThread(TParams&& params) - : TThread((const TParams&)params) - { - } - - TThread(TParams& params) - : TThread((const TParams&)params) - { - } - + } + + TThread(TParams&& params) + : TThread((const TParams&)params) + { + } + + TThread(TParams& params) + : TThread((const TParams&)params) + { + } + ~TThread(); void Start(); @@ -126,33 +126,33 @@ public: static bool CanGetCurrentThreadName(); private: - struct TCallableBase { - virtual ~TCallableBase() = default; - virtual void run() = 0; - - static void* ThreadWorker(void* arg) { - static_cast<TCallableBase*>(arg)->run(); - return nullptr; - } - }; - - template <typename Callable> - struct TCallableParams: public TCallableBase { - TCallableParams(Callable&& callable) - : Callable_(std::forward<Callable>(callable)) - { - } - - Callable Callable_; - - void run() override { - Callable_(); - } - }; - - TThread(TPrivateCtor, THolder<TCallableBase> callable); - -private: + struct TCallableBase { + virtual ~TCallableBase() = default; + virtual void run() = 0; + + static void* ThreadWorker(void* arg) { + static_cast<TCallableBase*>(arg)->run(); + return nullptr; + } + }; + + template <typename Callable> + struct TCallableParams: public TCallableBase { + TCallableParams(Callable&& callable) + : Callable_(std::forward<Callable>(callable)) + { + } + + Callable Callable_; + + void run() override { + Callable_(); + } + }; + + TThread(TPrivateCtor, THolder<TCallableBase> callable); + +private: class TImpl; THolder<TImpl> Impl_; }; diff --git a/util/system/thread_ut.cpp b/util/system/thread_ut.cpp index d820898fd5..0a50a36e59 100644 --- a/util/system/thread_ut.cpp +++ b/util/system/thread_ut.cpp @@ -178,52 +178,52 @@ Y_UNIT_TEST_SUITE(TSysThreadTest) { UNIT_ASSERT(sl.StackBegin); UNIT_ASSERT(sl.StackLength > 0); } - - Y_UNIT_TEST(TestFunc) { - std::atomic_bool flag = {false}; - TThread thread([&flag]() { flag = true; }); - - thread.Start(); - UNIT_ASSERT_VALUES_EQUAL(thread.Join(), nullptr); - UNIT_ASSERT(flag); - } - - Y_UNIT_TEST(TestCopyFunc) { - std::atomic_bool flag = {false}; - auto func = [&flag]() { flag = true; }; - - TThread thread(func); - thread.Start(); - UNIT_ASSERT_VALUES_EQUAL(thread.Join(), nullptr); - - TThread thread2(func); - thread2.Start(); - UNIT_ASSERT_VALUES_EQUAL(thread2.Join(), nullptr); - - UNIT_ASSERT(flag); - } - - Y_UNIT_TEST(TestCallable) { - std::atomic_bool flag = {false}; - + + Y_UNIT_TEST(TestFunc) { + std::atomic_bool flag = {false}; + TThread thread([&flag]() { flag = true; }); + + thread.Start(); + UNIT_ASSERT_VALUES_EQUAL(thread.Join(), nullptr); + UNIT_ASSERT(flag); + } + + Y_UNIT_TEST(TestCopyFunc) { + std::atomic_bool flag = {false}; + auto func = [&flag]() { flag = true; }; + + TThread thread(func); + thread.Start(); + UNIT_ASSERT_VALUES_EQUAL(thread.Join(), nullptr); + + TThread thread2(func); + thread2.Start(); + UNIT_ASSERT_VALUES_EQUAL(thread2.Join(), nullptr); + + UNIT_ASSERT(flag); + } + + Y_UNIT_TEST(TestCallable) { + std::atomic_bool flag = {false}; + struct TCallable: TMoveOnly { - std::atomic_bool* Flag_; - - TCallable(std::atomic_bool* flag) - : Flag_(flag) - { - } - - void operator()() { - *Flag_ = true; - } - }; - - TCallable foo(&flag); - TThread thread(std::move(foo)); - - thread.Start(); - UNIT_ASSERT_VALUES_EQUAL(thread.Join(), nullptr); - UNIT_ASSERT(flag); - } + std::atomic_bool* Flag_; + + TCallable(std::atomic_bool* flag) + : Flag_(flag) + { + } + + void operator()() { + *Flag_ = true; + } + }; + + TCallable foo(&flag); + TThread thread(std::move(foo)); + + thread.Start(); + UNIT_ASSERT_VALUES_EQUAL(thread.Join(), nullptr); + UNIT_ASSERT(flag); + } }; diff --git a/util/system/yassert.cpp b/util/system/yassert.cpp index 0f586648b7..e84055effa 100644 --- a/util/system/yassert.cpp +++ b/util/system/yassert.cpp @@ -5,7 +5,7 @@ #include "spinlock.h" #include "src_root.h" -#include <util/datetime/base.h> +#include <util/datetime/base.h> #include <util/generic/singleton.h> #include <util/generic/strbuf.h> #include <util/generic/string.h> @@ -63,14 +63,14 @@ void ::NPrivate::Panic(const TStaticBuf& file, int line, const char* function, c namespace NPrivate { [[noreturn]] Y_NO_INLINE void InternalPanicImpl(int line, const char* function, const char* expr, int, int, int, const TStringBuf file, const char* errorMessage, size_t errorMessageSize) noexcept try { TStringBuf errorMsg{errorMessage, errorMessageSize}; - const TString now = TInstant::Now().ToStringLocal(); - + const TString now = TInstant::Now().ToStringLocal(); + TString r; TStringOutput o(r); if (expr) { - o << "VERIFY failed (" << now << "): " << errorMsg << Endl; + o << "VERIFY failed (" << now << "): " << errorMsg << Endl; } else { - o << "FAIL (" << now << "): " << errorMsg << Endl; + o << "FAIL (" << now << "): " << errorMsg << Endl; } o << " " << file << ":" << line << Endl; if (expr) { |