Browse Source

Restoring authorship annotation for <dimko@yandex-team.ru>. Commit 2 of 2.

dimko 3 years ago
parent
commit
811ece47d0

+ 17 - 17
library/cpp/coroutine/engine/sockpool.h

@@ -9,9 +9,9 @@
 
 extern void SetCommonSockOpts(SOCKET sock, const struct sockaddr* sa = nullptr);
 
-class TSocketPool; 
- 
-class TPooledSocket { 
+class TSocketPool;
+
+class TPooledSocket {
     class TImpl: public TIntrusiveListItem<TImpl>, public TSimpleRefCount<TImpl, TImpl> {
     public:
         TImpl(SOCKET fd, TSocketPool* pool) noexcept
@@ -102,7 +102,7 @@ public:
     ~TPooledSocket() {
         if (UncaughtException() && !!Impl_) {
             Close();
-        } 
+        }
     }
 
     operator SOCKET() const noexcept {
@@ -119,9 +119,9 @@ public:
 
 private:
     TIntrusivePtr<TImpl> Impl_;
-}; 
- 
-struct TConnectData { 
+};
+
+struct TConnectData {
     TConnectData(TCont* cont, const TInstant& deadLine)
         : Cont(cont)
         , DeadLine(deadLine)
@@ -136,9 +136,9 @@ struct TConnectData {
 
     TCont* Cont;
     const TInstant DeadLine;
-}; 
- 
-class TSocketPool { 
+};
+
+class TSocketPool {
     friend class TPooledSocket::TImpl;
 
 public:
@@ -202,8 +202,8 @@ private:
 
             if (ret->IsOpen()) {
                 return ret.Release();
-            } 
-        } 
+            }
+        }
         return nullptr;
     }
 
@@ -220,12 +220,12 @@ private:
     using TSockets = TIntrusiveListWithAutoDelete<TPooledSocket::TImpl, TDelete>;
     TSockets Pool_;
     TMutex Mutex_;
-}; 
- 
+};
+
 inline void TPooledSocket::TImpl::ReturnToPool() noexcept {
     Pool_->Release(this);
-} 
- 
+}
+
 
 class TContIO: public IInputStream, public IOutputStream {
 public:
@@ -250,4 +250,4 @@ public:
 private:
     SOCKET Fd_;
     TCont* Cont_;
-}; 
+};

+ 7 - 7
util/datetime/cputimer.h

@@ -19,18 +19,18 @@ public:
 class TSimpleTimer {
     TInstant T;
 
-public: 
+public:
     TSimpleTimer() {
-        Reset(); 
-    } 
+        Reset();
+    }
     TDuration Get() const {
         return TInstant::Now() - T;
-    } 
+    }
     void Reset() {
         T = TInstant::Now();
-    } 
-}; 
- 
+    }
+};
+
 class TProfileTimer {
     TDuration T;
 

+ 28 - 28
util/generic/bitmap.h

@@ -310,7 +310,7 @@ struct TDynamicBitMapTraits {
 
 template <class TTraits>
 class TBitMapOps {
-public: 
+public:
     using TChunk = typename TTraits::TChunk;
     using TThis = TBitMapOps<TTraits>;
 
@@ -417,21 +417,21 @@ private:
 
 public:
     TBitMapOps() = default;
- 
+
     TBitMapOps(TChunk val) {
         Mask.Data[0] = val;
         Mask.Sanitize();
-    } 
- 
+    }
+
     TBitMapOps(const TThis&) = default;
- 
+
     template <class T>
     TBitMapOps(const TBitMapOps<T>& bitmap)
         : Mask(bitmap.Mask.Data, bitmap.Mask.GetChunkCapacity())
     {
         Mask.Sanitize();
-    } 
- 
+    }
+
     template <class T>
     Y_FORCE_INLINE bool operator==(const TBitMapOps<T>& bitmap) const {
         return Equal(bitmap);
@@ -589,19 +589,19 @@ public:
     }
 
     Y_FORCE_INLINE bool Test(size_t n) const {
-        return Get(n); 
-    } 
- 
+        return Get(n);
+    }
+
     Y_FORCE_INLINE TThis& Push(bool val) {
         LShift(1);
         return val ? Set(0) : *this;
-    } 
- 
+    }
+
     Y_FORCE_INLINE bool Pop() {
         bool val = Get(0);
         return RShift(1), val;
-    } 
- 
+    }
+
     // Clear entire bitmap. Current capacity is kept unchanged
     Y_FORCE_INLINE TThis& Clear() {
         for (size_t i = 0; i < Mask.GetChunkCapacity(); ++i) {
@@ -685,13 +685,13 @@ public:
         for (size_t i = bitmap.Mask.GetChunkCapacity(); i < Mask.GetChunkCapacity(); ++i)
             Mask.Data[i] = 0;
         return *this;
-    } 
- 
+    }
+
     template <class T>
     Y_FORCE_INLINE TThis& And(const TBitMapOps<T>& bitmap) {
         return And(TThis(bitmap));
-    } 
- 
+    }
+
     Y_FORCE_INLINE TThis& And(const TChunk& val) {
         Mask.Data[0] &= val;
         for (size_t i = 1; i < Mask.GetChunkCapacity(); ++i)
@@ -911,7 +911,7 @@ public:
         return l.Compare(r);
     }
 
-    size_t FirstNonZeroBit() const { 
+    size_t FirstNonZeroBit() const {
         for (size_t i = 0; i < Mask.GetChunkCapacity(); ++i) {
             if (Mask.Data[i]) {
                 // CountTrailingZeroBits() expects unsigned types not smaller than unsigned int. So, convert before calling
@@ -937,26 +937,26 @@ public:
                 const TChunk val = Mask.Data[i] & ((~TChunk(0)) << offset);
                 if (val) {
                     return BitsPerChunk * i + CountTrailingZeroBits(TIntType(val));
-                } 
+                }
                 // Continue with other chunks
                 ++i;
-            } 
+            }
 
             for (; i < Mask.GetChunkCapacity(); ++i) {
                 if (Mask.Data[i]) {
                     return BitsPerChunk * i + CountTrailingZeroBits(TIntType(Mask.Data[i]));
                 }
             }
-        } 
+        }
         return Size();
-    } 
- 
+    }
+
     Y_FORCE_INLINE size_t Count() const {
-        size_t count = 0; 
+        size_t count = 0;
         for (size_t i = 0; i < Mask.GetChunkCapacity(); ++i)
             count += ::NBitMapPrivate::CountBitsPrivate(Mask.Data[i]);
-        return count; 
-    } 
+        return count;
+    }
 
     void Save(IOutputStream* out) const {
         ::Save(out, ui8(sizeof(TChunk)));
@@ -1008,7 +1008,7 @@ public:
     constexpr size_t GetChunkCount() const noexcept {
         return Mask.GetChunkCapacity();
     }
-}; 
+};
 
 template <class X, class Y>
 inline TBitMapOps<X> operator&(const TBitMapOps<X>& x, const TBitMapOps<Y>& y) {

+ 41 - 41
util/generic/bitmap_ut.cpp

@@ -1,7 +1,7 @@
 #include "bitmap.h"
 
 #include <library/cpp/testing/unittest/registar.h>
- 
+
 #define INIT_BITMAP(bitmap, bits)                                \
     for (size_t i = 0; i < sizeof(bits) / sizeof(size_t); ++i) { \
         bitmap.Set(bits[i]);                                     \
@@ -40,23 +40,23 @@
 Y_UNIT_TEST_SUITE(TBitMapTest) {
     Y_UNIT_TEST(TestBitMap) {
         TBitMap<101> bitmap;
- 
+
         UNIT_ASSERT_EQUAL(bitmap.Size(), 101);
-        UNIT_ASSERT_EQUAL(bitmap.Count(), 0); 
-        UNIT_ASSERT_EQUAL(bitmap.FirstNonZeroBit(), 101); 
- 
+        UNIT_ASSERT_EQUAL(bitmap.Count(), 0);
+        UNIT_ASSERT_EQUAL(bitmap.FirstNonZeroBit(), 101);
+
         size_t initBits[] = {0, 50, 100, 45};
         INIT_BITMAP(bitmap, initBits);
-        bitmap.Reset(45); 
- 
-        UNIT_ASSERT_EQUAL(bitmap.FirstNonZeroBit(), 0); 
+        bitmap.Reset(45);
+
+        UNIT_ASSERT_EQUAL(bitmap.FirstNonZeroBit(), 0);
         size_t setBits[] = {0, 50, 100};
         CHECK_BITMAP(bitmap, setBits);
- 
+
         for (size_t i = 0; i < bitmap.Size(); ++i) {
             UNIT_ASSERT_EQUAL(bitmap.Get(i), bitmap.Test(i));
         }
- 
+
         UNIT_ASSERT_EQUAL(bitmap.Count(), 3);
 
         bitmap.Reset(0);
@@ -87,51 +87,51 @@ Y_UNIT_TEST_SUITE(TBitMapTest) {
         CHECK_BITMAP(bitmap, setBits);
 
         for (size_t i = 0; i < bitmap.Size(); ++i) {
-            UNIT_ASSERT_EQUAL(bitmap.Get(i), bitmap.Test(i)); 
+            UNIT_ASSERT_EQUAL(bitmap.Get(i), bitmap.Test(i));
         }
- 
-        UNIT_ASSERT_EQUAL(bitmap.Count(), 3); 
- 
-        bitmap.Reset(0); 
- 
-        UNIT_ASSERT_EQUAL(bitmap.FirstNonZeroBit(), 50); 
- 
-        bitmap.Clear(); 
- 
-        UNIT_ASSERT_EQUAL(bitmap.Count(), 0); 
+
+        UNIT_ASSERT_EQUAL(bitmap.Count(), 3);
+
+        bitmap.Reset(0);
+
+        UNIT_ASSERT_EQUAL(bitmap.FirstNonZeroBit(), 50);
+
+        bitmap.Clear();
+
+        UNIT_ASSERT_EQUAL(bitmap.Count(), 0);
         UNIT_ASSERT_EQUAL(bitmap.Empty(), true);
-    } 
- 
+    }
+
     template <class TBitMapImpl>
     void TestAndImpl() {
         TBitMapImpl bitmap1;
         TBitMapImpl bitmap2;
- 
+
         size_t initBits1[] = {10, 20, 50, 100};
         size_t initBits2[] = {10, 11, 22, 50};
 
         INIT_BITMAP(bitmap1, initBits1);
         INIT_BITMAP(bitmap2, initBits2);
 
-        bitmap1.And(bitmap2); 
- 
-        UNIT_ASSERT_EQUAL(bitmap1.Count(), 2); 
-        UNIT_ASSERT_EQUAL(bitmap2.Count(), 4); 
- 
+        bitmap1.And(bitmap2);
+
+        UNIT_ASSERT_EQUAL(bitmap1.Count(), 2);
+        UNIT_ASSERT_EQUAL(bitmap2.Count(), 4);
+
         size_t resBits[] = {10, 50};
- 
+
         CHECK_BITMAP(bitmap1, resBits);
         CHECK_BITMAP(bitmap2, initBits2);
-    } 
- 
+    }
+
     Y_UNIT_TEST(TestAndFixed) {
         TestAndImpl<TBitMap<101>>();
     }
- 
+
     Y_UNIT_TEST(TestAndDyn) {
         TestAndImpl<TDynBitMap>();
     }
- 
+
     template <class TBitMapImpl>
     void TestOrImpl() {
         TBitMapImpl bitmap1;
@@ -143,13 +143,13 @@ Y_UNIT_TEST_SUITE(TBitMapTest) {
         INIT_BITMAP(bitmap1, initBits1);
         INIT_BITMAP(bitmap2, initBits2);
 
-        bitmap1.Or(bitmap2); 
- 
-        UNIT_ASSERT_EQUAL(bitmap1.Count(), 7); 
-        UNIT_ASSERT_EQUAL(bitmap2.Count(), 4); 
- 
+        bitmap1.Or(bitmap2);
+
+        UNIT_ASSERT_EQUAL(bitmap1.Count(), 7);
+        UNIT_ASSERT_EQUAL(bitmap2.Count(), 4);
+
         size_t resBits[] = {0, 1, 10, 11, 22, 50, 76};
- 
+
         CHECK_BITMAP(bitmap1, resBits);
         CHECK_BITMAP(bitmap2, initBits2);
 
@@ -548,7 +548,7 @@ Y_UNIT_TEST_SUITE(TBitMapTest) {
         bitmapDynamic.Set(128);
         UNIT_ASSERT_UNEQUAL(bitmapFixed.Hash(), bitmapDynamic.Hash());
     }
- 
+
     Y_UNIT_TEST(TestSetResetRange) {
         // Single chunk
         using TBitMap1Chunk = TBitMap<64>;

+ 2 - 2
util/generic/strbase.h

@@ -35,7 +35,7 @@ namespace NStringPrivate {
 }
 
 template <typename TDerived, typename TCharType, typename TTraitsType = std::char_traits<TCharType>>
-class TStringBase { 
+class TStringBase {
     using TStringView = std::basic_string_view<TCharType>;
     using TStringViewWithTraits = std::basic_string_view<TCharType, TTraitsType>;
 
@@ -43,7 +43,7 @@ public:
     using TChar = TCharType;
     using TTraits = TTraitsType;
     using TSelf = TStringBase<TDerived, TChar, TTraits>;
- 
+
     using size_type = size_t;
     using difference_type = ptrdiff_t;
     static constexpr size_t npos = size_t(-1);

+ 8 - 8
util/system/daemon.cpp

@@ -13,13 +13,13 @@
 #endif
 
 #include "daemon.h"
- 
-#ifdef _unix_ 
+
+#ifdef _unix_
 using namespace NDaemonMaker;
- 
+
 static bool Fork(EParent parent) {
     pid_t pid = fork();
- 
+
     if (pid > 0) {
         int status = 0;
         while (waitpid(pid, &status, 0) < 0 && errno == EINTR) {
@@ -32,13 +32,13 @@ static bool Fork(EParent parent) {
     } else if (pid < 0) {
         ythrow TSystemError() << "Cannot fork";
     }
- 
+
     if (setsid() < 0) {
         ythrow TSystemError() << "Cannot setsid";
     }
- 
+
     pid = fork();
- 
+
     if (pid > 0) {
         _exit(0);
     } else if (pid < 0) {
@@ -46,7 +46,7 @@ static bool Fork(EParent parent) {
     }
     return false;
 }
- 
+
 #endif
 
 static void CloseFromToExcept(int from, int to, const int* except) {

+ 2 - 2
util/system/daemon.h

@@ -1,11 +1,11 @@
 #pragma once
- 
+
 namespace NDaemonMaker {
     enum ECloseDescriptors {
         closeAll = 0,
         closeStdIoOnly
     };
- 
+
     enum EStdIoDescriptors {
         openNone = 0,
         openDevNull,

+ 2 - 2
util/system/error.cpp

@@ -84,9 +84,9 @@ void LastSystemErrorText(char* str, size_t size, int code) {
     FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 0, code, 0, str, DWORD(size), 0);
     Strip(str);
 #elif defined(_sun_)
-    strfcpy(str, strerror(code), size); 
+    strfcpy(str, strerror(code), size);
 #elif defined(_freebsd_) || defined(_darwin_) || defined(_musl_) || defined(_bionic_)
-    strerror_r(code, str, size); 
+    strerror_r(code, str, size);
 #elif defined(_linux_) | defined(_cygwin_)
     char* msg = strerror_r(code, str, size);
     strncpy(str, msg, size);