diff options
| author | psushin <[email protected]> | 2022-02-10 16:49:19 +0300 | 
|---|---|---|
| committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:49:19 +0300 | 
| commit | 4ba0e0cae125e5faa4b5664a88c54ab6af93ea4d (patch) | |
| tree | 1c00333319988270b78d83715b1e56fddfa7028e /library/cpp/yt | |
| parent | 7622df751aca736b9e1e20015e6787d5a65643b0 (diff) | |
Restoring authorship annotation for <[email protected]>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/yt')
| -rw-r--r-- | library/cpp/yt/coding/varint.h | 40 | ||||
| -rw-r--r-- | library/cpp/yt/memory/intrusive_ptr.h | 20 | ||||
| -rw-r--r-- | library/cpp/yt/memory/ref.h | 4 | ||||
| -rw-r--r-- | library/cpp/yt/memory/ref_tracked.h | 58 | ||||
| -rw-r--r-- | library/cpp/yt/memory/weak_ptr.h | 14 | ||||
| -rw-r--r-- | library/cpp/yt/small_containers/compact_set.h | 70 | 
6 files changed, 103 insertions, 103 deletions
diff --git a/library/cpp/yt/coding/varint.h b/library/cpp/yt/coding/varint.h index c5399f8b069..b3b51056cdf 100644 --- a/library/cpp/yt/coding/varint.h +++ b/library/cpp/yt/coding/varint.h @@ -1,55 +1,55 @@ -#pragma once - +#pragma once  +   #include <library/cpp/yt/exception/exception.h> -#include <util/system/defaults.h> - +#include <util/system/defaults.h>  +   #include <util/stream/input.h>  #include <util/stream/output.h> - -namespace NYT { - -//////////////////////////////////////////////////////////////////////////////// - +  +namespace NYT {  +  +////////////////////////////////////////////////////////////////////////////////  +   constexpr size_t MaxVarInt64Size = (8 * sizeof(ui64) - 1) / 7 + 1;  constexpr size_t MaxVarUint64Size = (8 * sizeof(ui64) - 1) / 7 + 1; - +   constexpr size_t MaxVarInt32Size = (8 * sizeof(ui32) - 1) / 7 + 1;  constexpr size_t MaxVarUint32Size = (8 * sizeof(ui32) - 1) / 7 + 1;  // Various functions to read/write varints. - -// Returns the number of bytes written. +  +// Returns the number of bytes written.   int WriteVarUint64(IOutputStream* output, ui64 value);  int WriteVarUint32(IOutputStream* output, ui32 value);  int WriteVarInt32(IOutputStream* output, i32 value);  int WriteVarInt64(IOutputStream* output, i64 value); - +   int WriteVarUint64(char* output, ui64 value);  int WriteVarUint32(char* output, ui32 value);  int WriteVarInt32(char* output, i32 value);  int WriteVarInt64(char* output, i64 value); - -// Returns the number of bytes read. +  +// Returns the number of bytes read.   int ReadVarUint64(IInputStream* input, ui64* value);  int ReadVarUint32(IInputStream* input, ui32* value);  int ReadVarInt32(IInputStream* input, i32* value);  int ReadVarInt64(IInputStream* input, i64* value); - +   int ReadVarUint64(const char* input, ui64* value);  int ReadVarUint32(const char* input, ui32* value);  int ReadVarInt32(const char* input, i32* value);  int ReadVarInt64(const char* input, i64* value); - +   // Throws exception if integer is not complete when `end' is reached.  int ReadVarUint64(const char* input, const char* end, ui64* value);  int ReadVarUint32(const char* input, const char* end, ui32* value);  int ReadVarInt32(const char* input, const char* end, i32* value);  int ReadVarInt64(const char* input, const char* end, i64* value); -//////////////////////////////////////////////////////////////////////////////// - -} // namespace NYT +////////////////////////////////////////////////////////////////////////////////  +  +} // namespace NYT   #define VARINT_INL_H_  #include "varint-inl.h" diff --git a/library/cpp/yt/memory/intrusive_ptr.h b/library/cpp/yt/memory/intrusive_ptr.h index 3dead7db1d7..74d1482854f 100644 --- a/library/cpp/yt/memory/intrusive_ptr.h +++ b/library/cpp/yt/memory/intrusive_ptr.h @@ -99,7 +99,7 @@ public:      template <class U>      TIntrusivePtr& operator=(const TIntrusivePtr<U>& other) noexcept      { -        static_assert( +        static_assert(               std::is_convertible_v<U*, T*>,              "U* must be convertible to T*");          static_assert( @@ -112,7 +112,7 @@ public:      //! Move assignment operator.      TIntrusivePtr& operator=(TIntrusivePtr&& other) noexcept      { -        TIntrusivePtr(std::move(other)).Swap(*this); +        TIntrusivePtr(std::move(other)).Swap(*this);           return *this;      } @@ -120,13 +120,13 @@ public:      template <class U>      TIntrusivePtr& operator=(TIntrusivePtr<U>&& other) noexcept      { -        static_assert( +        static_assert(               std::is_convertible_v<U*, T*>,              "U* must be convertible to T*");          static_assert(              std::is_base_of_v<TRefCountedBase, T>,              "Cast allowed only for types derived from TRefCountedBase"); -        TIntrusivePtr(std::move(other)).Swap(*this); +        TIntrusivePtr(std::move(other)).Swap(*this);           return *this;      } @@ -270,7 +270,7 @@ bool operator>(const TIntrusivePtr<T>& lhs, const TIntrusivePtr<T>& rhs)  template <class T, class U>  bool operator==(const TIntrusivePtr<T>& lhs, const TIntrusivePtr<U>& rhs)  { -    static_assert( +    static_assert(           std::is_convertible_v<U*, T*>,          "U* must be convertible to T*");      return lhs.Get() == rhs.Get(); @@ -279,7 +279,7 @@ bool operator==(const TIntrusivePtr<T>& lhs, const TIntrusivePtr<U>& rhs)  template <class T, class U>  bool operator!=(const TIntrusivePtr<T>& lhs, const TIntrusivePtr<U>& rhs)  { -    static_assert( +    static_assert(           std::is_convertible_v<U*, T*>,          "U* must be convertible to T*");      return lhs.Get() != rhs.Get(); @@ -288,7 +288,7 @@ bool operator!=(const TIntrusivePtr<T>& lhs, const TIntrusivePtr<U>& rhs)  template <class T, class U>  bool operator==(const TIntrusivePtr<T>& lhs, U* rhs)  { -    static_assert( +    static_assert(           std::is_convertible_v<U*, T*>,          "U* must be convertible to T*");      return lhs.Get() == rhs; @@ -297,7 +297,7 @@ bool operator==(const TIntrusivePtr<T>& lhs, U* rhs)  template <class T, class U>  bool operator!=(const TIntrusivePtr<T>& lhs, U* rhs)  { -    static_assert( +    static_assert(           std::is_convertible_v<U*, T*>,          "U* must be convertible to T*");      return lhs.Get() != rhs; @@ -306,7 +306,7 @@ bool operator!=(const TIntrusivePtr<T>& lhs, U* rhs)  template <class T, class U>  bool operator==(T* lhs, const TIntrusivePtr<U>& rhs)  { -    static_assert( +    static_assert(           std::is_convertible_v<U*, T*>,          "U* must be convertible to T*");      return lhs == rhs.Get(); @@ -315,7 +315,7 @@ bool operator==(T* lhs, const TIntrusivePtr<U>& rhs)  template <class T, class U>  bool operator!=(T* lhs, const TIntrusivePtr<U>& rhs)  { -    static_assert( +    static_assert(           std::is_convertible_v<U*, T*>,          "U* must be convertible to T*");      return lhs != rhs.Get(); diff --git a/library/cpp/yt/memory/ref.h b/library/cpp/yt/memory/ref.h index 73d19d9013e..31d171cf0d6 100644 --- a/library/cpp/yt/memory/ref.h +++ b/library/cpp/yt/memory/ref.h @@ -307,8 +307,8 @@ private:  const TSharedRef* begin(const TSharedRefArray& array);  const TSharedRef* end(const TSharedRefArray& array); -//////////////////////////////////////////////////////////////////////////////// - +////////////////////////////////////////////////////////////////////////////////  +   struct TDefaultSharedRefArrayBuilderTag { };  //! A helper for creating TSharedRefArray. diff --git a/library/cpp/yt/memory/ref_tracked.h b/library/cpp/yt/memory/ref_tracked.h index 75c1eb59850..608c1bbe3ad 100644 --- a/library/cpp/yt/memory/ref_tracked.h +++ b/library/cpp/yt/memory/ref_tracked.h @@ -1,17 +1,17 @@ -#pragma once - +#pragma once  +   #include <library/cpp/yt/misc/port.h>  #include <library/cpp/yt/misc/source_location.h> - +   #include <util/system/defaults.h>  #include <atomic>  #include <typeinfo> -namespace NYT { - -//////////////////////////////////////////////////////////////////////////////// - +namespace NYT {  +  +////////////////////////////////////////////////////////////////////////////////  +   using TRefCountedTypeCookie = int;  const int NullRefCountedTypeCookie = -1; @@ -64,24 +64,24 @@ TRefCountedTypeCookie GetRefCountedTypeCookieWithLocation(  //////////////////////////////////////////////////////////////////////////////// -//! A lightweight mix-in that integrates any class into TRefCountedTracker statistics. -/*! - *  |T| must be the actual derived type. +//! A lightweight mix-in that integrates any class into TRefCountedTracker statistics.  +/*!  + *  |T| must be the actual derived type.    * - *  This mix-in provides statistical tracking only, |T| is responsible for implementing - *  lifetime management on its own. - */ -template <class T> -class TRefTracked -{ -public: + *  This mix-in provides statistical tracking only, |T| is responsible for implementing  + *  lifetime management on its own.  + */  +template <class T>  +class TRefTracked  +{  +public:   #ifdef YT_ENABLE_REF_COUNTED_TRACKING -    TRefTracked() -    { +    TRefTracked()  +    {           auto cookie = GetRefCountedTypeCookie<T>();          TRefCountedTrackerFacade::AllocateInstance(cookie); -    } - +    }  +       TRefTracked(const TRefTracked&)      {          auto cookie = GetRefCountedTypeCookie<T>(); @@ -94,17 +94,17 @@ public:          TRefCountedTrackerFacade::AllocateInstance(cookie);      } -    ~TRefTracked() -    { +    ~TRefTracked()  +    {           auto cookie = GetRefCountedTypeCookie<T>();          TRefCountedTrackerFacade::FreeInstance(cookie);      } -#endif -}; - -//////////////////////////////////////////////////////////////////////////////// - -} // namespace NYT +#endif  +};  +  +////////////////////////////////////////////////////////////////////////////////  +  +} // namespace NYT   #define REF_TRACKED_INL_H_  #include "ref_tracked-inl.h" diff --git a/library/cpp/yt/memory/weak_ptr.h b/library/cpp/yt/memory/weak_ptr.h index 25a242bb8a5..ef6de44546a 100644 --- a/library/cpp/yt/memory/weak_ptr.h +++ b/library/cpp/yt/memory/weak_ptr.h @@ -102,7 +102,7 @@ public:      template <class U>      TWeakPtr& operator=(const TIntrusivePtr<U>& ptr) noexcept      { -        static_assert( +        static_assert(               std::is_convertible_v<U*, T*>,              "U* must be convertible to T*");          TWeakPtr(ptr).Swap(*this); @@ -120,7 +120,7 @@ public:      template <class U>      TWeakPtr& operator=(const TWeakPtr<U>& other) noexcept      { -        static_assert( +        static_assert(               std::is_convertible_v<U*, T*>,              "U* must be convertible to T*");          TWeakPtr(other).Swap(*this); @@ -141,7 +141,7 @@ public:          static_assert(              std::is_convertible_v<U*, T*>,              "U* must be convertible to T*"); -        TWeakPtr(std::move(other)).Swap(*this); +        TWeakPtr(std::move(other)).Swap(*this);           return *this;      } @@ -161,7 +161,7 @@ public:      template <class U>      void Reset(const TIntrusivePtr<U>& ptr) // noexcept      { -        static_assert( +        static_assert(               std::is_convertible_v<U*, T*>,              "U* must be convertible to T*");          TWeakPtr(ptr).Swap(*this); @@ -267,7 +267,7 @@ int ResetAndGetResidualRefCount(TIntrusivePtr<T>& pointer)  //////////////////////////////////////////////////////////////////////////////// -// TODO(sandello): Kill comparsions. +// TODO(sandello): Kill comparsions.   template <class T>  bool operator<(const TWeakPtr<T>& lhs, const TWeakPtr<T>& rhs)  { @@ -283,7 +283,7 @@ bool operator>(const TWeakPtr<T>& lhs, const TWeakPtr<T>& rhs)  template <class T, class U>  bool operator==(const TWeakPtr<T>& lhs, const TWeakPtr<U>& rhs)  { -    static_assert( +    static_assert(           std::is_convertible_v<U*, T*>,          "U* must be convertible to T*");      return lhs.Lock().Get() == rhs.Lock().Get(); @@ -292,7 +292,7 @@ bool operator==(const TWeakPtr<T>& lhs, const TWeakPtr<U>& rhs)  template <class T, class U>  bool operator!=(const TWeakPtr<T>& lhs, const TWeakPtr<U>& rhs)  { -    static_assert( +    static_assert(           std::is_convertible_v<U*, T*>,          "U* must be convertible to T*");      return lhs.Lock().Get() != rhs.Lock().Get(); diff --git a/library/cpp/yt/small_containers/compact_set.h b/library/cpp/yt/small_containers/compact_set.h index 2ca8713ea72..bab360420ea 100644 --- a/library/cpp/yt/small_containers/compact_set.h +++ b/library/cpp/yt/small_containers/compact_set.h @@ -1,34 +1,34 @@  //===- llvm/ADT/SmallSet.h - 'Normally small' sets --------------*- C++ -*-===// -// -//                     The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// +//  +//                     The LLVM Compiler Infrastructure  +//  +// This file is distributed under the University of Illinois Open Source  +// License. See LICENSE.TXT for details.  +//  +//===----------------------------------------------------------------------===//  +//   // This file defines the TCompactSet class. -// -//===----------------------------------------------------------------------===// - -#pragma once - +//  +//===----------------------------------------------------------------------===//  +  +#pragma once  +   #include "compact_vector.h" - +   #include <util/system/yassert.h>  #include <cstddef>  #include <iterator> -#include <set> +#include <set>   #include <type_traits> - -namespace NYT { - +  +namespace NYT {  +   /// TCompactSet - This maintains a set of unique values, optimizing for the case -/// when the set is small (less than N).  In this case, the set can be -/// maintained with no mallocs.  If the set gets large, we expand to using an -/// std::set to maintain reasonable lookup times. -/// +/// when the set is small (less than N).  In this case, the set can be  +/// maintained with no mallocs.  If the set gets large, we expand to using an  +/// std::set to maintain reasonable lookup times.  +///   /// Note that any modification of the set may invalidate *all* iterators.  template <typename T, unsigned N, typename C = std::less<T>>  class TCompactSet @@ -43,29 +43,29 @@ private:      using TSetConstIterator = typename std::set<T, C>::const_iterator;      using TVectorConstIterator = typename TCompactVector<T, N>::const_iterator; -public: +public:       class const_iterator;      using size_type = std::size_t; - +       TCompactSet() {} - +       [[nodiscard]] bool empty() const;      size_type size() const; - +       const T& front() const; - +       /// count - Return true if the element is in the set.      size_type count(const T& v) const; - +       /// insert - Insert an element into the set if it isn't already there.      std::pair<const_iterator, bool> insert(const T& v); - +       template <typename TIter>      void insert(TIter i, TIter e); - +       bool erase(const T& v); - +       void clear();      const_iterator begin() const; @@ -74,11 +74,11 @@ public:      const_iterator end() const;      const_iterator cend() const; -private: +private:       bool IsSmall() const; -}; - -} // namespace NYT +};  +  +} // namespace NYT   #define COMPACT_SET_INL_H_  #include "compact_set-inl.h"  | 
