aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/messagebus/misc
diff options
context:
space:
mode:
authorAnton Samokhvalov <pg83@yandex.ru>2022-02-10 16:45:17 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:17 +0300
commitd3a398281c6fd1d3672036cb2d63f842d2cb28c5 (patch)
treedd4bd3ca0f36b817e96812825ffaf10d645803f2 /library/cpp/messagebus/misc
parent72cb13b4aff9bc9cf22e49251bc8fd143f82538f (diff)
downloadydb-d3a398281c6fd1d3672036cb2d63f842d2cb28c5.tar.gz
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/messagebus/misc')
-rw-r--r--library/cpp/messagebus/misc/atomic_box.h18
-rw-r--r--library/cpp/messagebus/misc/granup.h28
-rw-r--r--library/cpp/messagebus/misc/test_sync.h6
-rw-r--r--library/cpp/messagebus/misc/tokenquota.h30
-rw-r--r--library/cpp/messagebus/misc/weak_ptr.h26
-rw-r--r--library/cpp/messagebus/misc/weak_ptr_ut.cpp14
6 files changed, 61 insertions, 61 deletions
diff --git a/library/cpp/messagebus/misc/atomic_box.h b/library/cpp/messagebus/misc/atomic_box.h
index c36b6c747f..401621f933 100644
--- a/library/cpp/messagebus/misc/atomic_box.h
+++ b/library/cpp/messagebus/misc/atomic_box.h
@@ -12,23 +12,23 @@ private:
T ValueForDebugger;
};
- static_assert(sizeof(T) <= sizeof(TAtomic), "expect sizeof(T) <= sizeof(TAtomic)");
-
+ static_assert(sizeof(T) <= sizeof(TAtomic), "expect sizeof(T) <= sizeof(TAtomic)");
+
public:
- TAtomicBox(T value = T())
- : Value(value)
- {
- }
+ TAtomicBox(T value = T())
+ : Value(value)
+ {
+ }
void Set(T value) {
- AtomicSet(Value, (TAtomic)value);
+ AtomicSet(Value, (TAtomic)value);
}
T Get() const {
- return (T)AtomicGet(Value);
+ return (T)AtomicGet(Value);
}
bool CompareAndSet(T expected, T set) {
- return AtomicCas(&Value, (TAtomicBase)set, (TAtomicBase)expected);
+ return AtomicCas(&Value, (TAtomicBase)set, (TAtomicBase)expected);
}
};
diff --git a/library/cpp/messagebus/misc/granup.h b/library/cpp/messagebus/misc/granup.h
index ff6cf522b4..36ecfebc93 100644
--- a/library/cpp/messagebus/misc/granup.h
+++ b/library/cpp/messagebus/misc/granup.h
@@ -12,29 +12,29 @@ namespace NBus {
TGranUp(TDuration gran)
: Gran(gran)
, Next(TInstant::MicroSeconds(0))
- {
- }
+ {
+ }
- template <typename TFunctor>
- void Update(TFunctor functor, TInstant now, bool force = false) {
- if (force || now > Next)
+ template <typename TFunctor>
+ void Update(TFunctor functor, TInstant now, bool force = false) {
+ if (force || now > Next)
Set(functor(), now);
}
- void Update(const TItem& item, TInstant now, bool force = false) {
- if (force || now > Next)
+ void Update(const TItem& item, TInstant now, bool force = false) {
+ if (force || now > Next)
Set(item, now);
}
- TItem Get() const noexcept {
- TGuard<TLocker> guard(Lock);
+ TItem Get() const noexcept {
+ TGuard<TLocker> guard(Lock);
return Item;
}
protected:
- void Set(const TItem& item, TInstant now) {
- TGuard<TLocker> guard(Lock);
+ void Set(const TItem& item, TInstant now) {
+ TGuard<TLocker> guard(Lock);
Item = item;
@@ -43,8 +43,8 @@ namespace NBus {
private:
const TDuration Gran;
- TLocker Lock;
- TItem Item;
- TInstant Next;
+ TLocker Lock;
+ TItem Item;
+ TInstant Next;
};
}
diff --git a/library/cpp/messagebus/misc/test_sync.h b/library/cpp/messagebus/misc/test_sync.h
index 9a6a718f7b..be3f4f20b8 100644
--- a/library/cpp/messagebus/misc/test_sync.h
+++ b/library/cpp/messagebus/misc/test_sync.h
@@ -9,12 +9,12 @@ private:
TMutex Mutex;
TCondVar CondVar;
-
+
public:
TTestSync()
: Current(0)
- {
- }
+ {
+ }
void Inc() {
TGuard<TMutex> guard(Mutex);
diff --git a/library/cpp/messagebus/misc/tokenquota.h b/library/cpp/messagebus/misc/tokenquota.h
index d5bdd79625..190547fa54 100644
--- a/library/cpp/messagebus/misc/tokenquota.h
+++ b/library/cpp/messagebus/misc/tokenquota.h
@@ -25,26 +25,26 @@ namespace NBus {
Y_UNUSED(padd_);
}
- bool Acquire(TAtomic level = 1, bool force = false) {
- level = Max(TAtomicBase(level), TAtomicBase(1));
+ bool Acquire(TAtomic level = 1, bool force = false) {
+ level = Max(TAtomicBase(level), TAtomicBase(1));
- if (Enabled && (Acquired < level || force)) {
+ if (Enabled && (Acquired < level || force)) {
Acquired += AtomicSwap(&Tokens_, 0);
}
return !Enabled || Acquired >= level;
}
- void Consume(size_t items) {
- if (Enabled) {
+ void Consume(size_t items) {
+ if (Enabled) {
Y_ASSERT(Acquired >= TAtomicBase(items));
Acquired -= items;
}
}
- bool Return(size_t items_) noexcept {
- if (!Enabled || items_ == 0)
+ bool Return(size_t items_) noexcept {
+ if (!Enabled || items_ == 0)
return false;
const TAtomic items = items_;
@@ -53,31 +53,31 @@ namespace NBus {
return (value - items < WakeLev && value >= WakeLev);
}
- bool IsEnabled() const noexcept {
+ bool IsEnabled() const noexcept {
return Enabled;
}
- bool IsAboveWake() const noexcept {
+ bool IsAboveWake() const noexcept {
return !Enabled || (WakeLev <= AtomicGet(Tokens_));
}
- size_t Tokens() const noexcept {
+ size_t Tokens() const noexcept {
return Acquired + AtomicGet(Tokens_);
}
- size_t Check(const TAtomic level) const noexcept {
+ size_t Check(const TAtomic level) const noexcept {
return !Enabled || level <= Acquired;
}
private:
- bool Enabled;
- TAtomicBase Acquired;
+ bool Enabled;
+ TAtomicBase Acquired;
const TAtomicBase WakeLev;
- TAtomic Tokens_;
+ TAtomic Tokens_;
/* This padd requires for align Tokens_ member on its own
CPU cacheline. */
- ui64 padd_;
+ ui64 padd_;
};
}
diff --git a/library/cpp/messagebus/misc/weak_ptr.h b/library/cpp/messagebus/misc/weak_ptr.h
index ac20cd7d43..70fdeb0e2a 100644
--- a/library/cpp/messagebus/misc/weak_ptr.h
+++ b/library/cpp/messagebus/misc/weak_ptr.h
@@ -8,18 +8,18 @@ struct TWeakPtr;
template <typename TSelf>
struct TWeakRefCounted {
- template <typename>
- friend struct TWeakPtr;
-
+ template <typename>
+ friend struct TWeakPtr;
+
private:
- struct TRef: public TAtomicRefCount<TRef> {
+ struct TRef: public TAtomicRefCount<TRef> {
TMutex Mutex;
TSelf* Outer;
- TRef(TSelf* outer)
- : Outer(outer)
- {
- }
+ TRef(TSelf* outer)
+ : Outer(outer)
+ {
+ }
void Release() {
TGuard<TMutex> g(Mutex);
@@ -40,8 +40,8 @@ private:
public:
TWeakRefCounted()
: RefPtr(new TRef(static_cast<TSelf*>(this)))
- {
- }
+ {
+ }
void Ref() {
Counter.Inc();
@@ -72,10 +72,10 @@ struct TWeakPtr {
private:
typedef TIntrusivePtr<typename T::TRef> TRefPtr;
TRefPtr RefPtr;
-
+
public:
- TWeakPtr() {
- }
+ TWeakPtr() {
+ }
TWeakPtr(T* t) {
if (!!t) {
diff --git a/library/cpp/messagebus/misc/weak_ptr_ut.cpp b/library/cpp/messagebus/misc/weak_ptr_ut.cpp
index 9677ae21b5..5a325278db 100644
--- a/library/cpp/messagebus/misc/weak_ptr_ut.cpp
+++ b/library/cpp/messagebus/misc/weak_ptr_ut.cpp
@@ -6,13 +6,13 @@ Y_UNIT_TEST_SUITE(TWeakPtrTest) {
struct TWeakPtrTester: public TWeakRefCounted<TWeakPtrTester> {
int* const CounterPtr;
- TWeakPtrTester(int* counterPtr)
- : CounterPtr(counterPtr)
- {
- }
- ~TWeakPtrTester() {
- ++*CounterPtr;
- }
+ TWeakPtrTester(int* counterPtr)
+ : CounterPtr(counterPtr)
+ {
+ }
+ ~TWeakPtrTester() {
+ ++*CounterPtr;
+ }
};
Y_UNIT_TEST(Simple) {