aboutsummaryrefslogtreecommitdiffstats
path: root/util/system
diff options
context:
space:
mode:
authorspacelord <spacelord@yandex-team.ru>2022-02-10 16:48:15 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:48:15 +0300
commit16747e4f77455cca4932df21eb76f12cb0a97a5c (patch)
tree4dd6da4102d99d0d69dec53c1050d290a850a9f2 /util/system
parenta817f5de12611ec73085eba17f8ec7740a46bdb7 (diff)
downloadydb-16747e4f77455cca4932df21eb76f12cb0a97a5c.tar.gz
Restoring authorship annotation for <spacelord@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util/system')
-rw-r--r--util/system/atexit.h4
-rw-r--r--util/system/atomic_ut.cpp6
-rw-r--r--util/system/backtrace_ut.cpp2
-rw-r--r--util/system/condvar.cpp4
-rw-r--r--util/system/condvar_ut.cpp2
-rw-r--r--util/system/event.h114
-rw-r--r--util/system/event_ut.cpp90
-rw-r--r--util/system/fasttime.cpp4
-rw-r--r--util/system/fstat.cpp4
-rw-r--r--util/system/hp_timer.h2
-rw-r--r--util/system/mutex_ut.cpp2
-rw-r--r--util/system/pipe.h4
-rw-r--r--util/system/rwlock_ut.cpp2
-rw-r--r--util/system/shellcommand.cpp10
-rw-r--r--util/system/shellcommand.h2
-rw-r--r--util/system/sys_alloc.h26
-rw-r--r--util/system/thread.cpp10
-rw-r--r--util/system/thread.h4
-rw-r--r--util/system/tls.cpp4
-rw-r--r--util/system/tls.h2
20 files changed, 149 insertions, 149 deletions
diff --git a/util/system/atexit.h b/util/system/atexit.h
index eb3188615c..ed06b86e8e 100644
--- a/util/system/atexit.h
+++ b/util/system/atexit.h
@@ -2,8 +2,8 @@
#include "defaults.h"
-using TAtExitFunc = void (*)(void*);
-using TTraditionalAtExitFunc = void (*)();
+using TAtExitFunc = void (*)(void*);
+using TTraditionalAtExitFunc = void (*)();
void AtExit(TAtExitFunc func, void* ctx);
void AtExit(TAtExitFunc func, void* ctx, size_t priority);
diff --git a/util/system/atomic_ut.cpp b/util/system/atomic_ut.cpp
index 07211ffba7..896d375c09 100644
--- a/util/system/atomic_ut.cpp
+++ b/util/system/atomic_ut.cpp
@@ -194,12 +194,12 @@ UNIT_TEST_SUITE_REGISTRATION(TAtomicTest<TAtomic>);
// chooses type *other than* T1
template <typename T1, typename T2, typename T3>
struct TChooser {
- using TdType = T2;
+ using TdType = T2;
};
template <typename T1, typename T2>
struct TChooser<T1, T1, T2> {
- using TdType = T2;
+ using TdType = T2;
};
template <typename T1>
@@ -208,7 +208,7 @@ struct TChooser<T1, T1, T1> {};
#if defined(__IOS__) && defined(_32_)
using TAltAtomic = int;
#else
-using TAltAtomic = volatile TChooser<TAtomicBase, long, long long>::TdType;
+using TAltAtomic = volatile TChooser<TAtomicBase, long, long long>::TdType;
#endif
class TTTest: public TAtomicTest<TAltAtomic> {
diff --git a/util/system/backtrace_ut.cpp b/util/system/backtrace_ut.cpp
index 9b5ead71bc..f0c6943f6b 100644
--- a/util/system/backtrace_ut.cpp
+++ b/util/system/backtrace_ut.cpp
@@ -5,7 +5,7 @@
#include <util/stream/output.h>
-using PFunc = int (*)(void**, size_t);
+using PFunc = int (*)(void**, size_t);
int Dbg1(void** buf, size_t len) {
volatile int ret = (int)BackTrace(buf, len);
diff --git a/util/system/condvar.cpp b/util/system/condvar.cpp
index 62f3d22356..9e28eb5fd1 100644
--- a/util/system/condvar.cpp
+++ b/util/system/condvar.cpp
@@ -19,12 +19,12 @@
namespace {
class TCondVarImpl {
- using TLock = TAdaptiveLock;
+ using TLock = TAdaptiveLock;
struct TWaitEvent: public TIntrusiveListItem<TWaitEvent>, public TSystemEvent {
};
- using TWaitEvents = TIntrusiveList<TWaitEvent>;
+ using TWaitEvents = TIntrusiveList<TWaitEvent>;
public:
inline ~TCondVarImpl() {
diff --git a/util/system/condvar_ut.cpp b/util/system/condvar_ut.cpp
index 5130a18d32..5ea8c59f04 100644
--- a/util/system/condvar_ut.cpp
+++ b/util/system/condvar_ut.cpp
@@ -40,7 +40,7 @@ class TCondVarTest: public TTestBase {
class TThreadTask: public IObjectInQueue {
public:
- using PFunc = void (TThreadTask::*)(void);
+ using PFunc = void (TThreadTask::*)(void);
TThreadTask(PFunc func, size_t id, size_t totalIds, TSharedData& data)
: Func_(func)
diff --git a/util/system/event.h b/util/system/event.h
index cab2fc478a..d583cd1fe9 100644
--- a/util/system/event.h
+++ b/util/system/event.h
@@ -3,21 +3,21 @@
#include <util/generic/ptr.h>
#include <util/datetime/base.h>
-struct TEventResetType {
+struct TEventResetType {
enum ResetMode {
rAuto, // the state will be nonsignaled after Wait() returns
rManual, // we need call Reset() to set the state to nonsignaled.
};
-};
+};
-/**
- * DEPRECATED!
- *
- * Use TAutoEvent, TManualEvent for the direct replacement.
+/**
+ * DEPRECATED!
+ *
+ * Use TAutoEvent, TManualEvent for the direct replacement.
* Use TManualEvent to prevent SEGFAULT (http://nga.at.yandex-team.ru/5772).
- */
+ */
class TSystemEvent: public TEventResetType {
-public:
+public:
TSystemEvent(ResetMode rmode = rManual);
TSystemEvent(const TSystemEvent& other) noexcept;
TSystemEvent& operator=(const TSystemEvent& other) noexcept;
@@ -61,62 +61,62 @@ private:
class TEvImpl;
TIntrusivePtr<TEvImpl> EvImpl_;
};
-
+
class TAutoEvent: public TSystemEvent {
-public:
- TAutoEvent()
+public:
+ TAutoEvent()
: TSystemEvent(TSystemEvent::rAuto)
- {
- }
-
-private:
- void Reset() noexcept;
-};
-
-/**
- * Prevents from a "shortcut problem" (see http://nga.at.yandex-team.ru/5772): if Wait will be called after Signaled
- * flag set to true in Signal method but before CondVar.BroadCast - Wait will shortcut (without actual wait on condvar).
- * If Wait thread will destruct event - Signal thread will do broadcast on a destructed CondVar.
- */
-class TManualEvent {
-public:
- TManualEvent()
- : Ev(TEventResetType::rManual)
- {
- }
-
- void Reset() noexcept {
+ {
+ }
+
+private:
+ void Reset() noexcept;
+};
+
+/**
+ * Prevents from a "shortcut problem" (see http://nga.at.yandex-team.ru/5772): if Wait will be called after Signaled
+ * flag set to true in Signal method but before CondVar.BroadCast - Wait will shortcut (without actual wait on condvar).
+ * If Wait thread will destruct event - Signal thread will do broadcast on a destructed CondVar.
+ */
+class TManualEvent {
+public:
+ TManualEvent()
+ : Ev(TEventResetType::rManual)
+ {
+ }
+
+ void Reset() noexcept {
TSystemEvent{Ev}.Reset();
- }
-
- void Signal() noexcept {
+ }
+
+ void Signal() noexcept {
TSystemEvent{Ev}.Signal();
- }
-
- /** return true if signaled, false if timed out. */
- bool WaitD(TInstant deadLine) noexcept {
+ }
+
+ /** return true if signaled, false if timed out. */
+ bool WaitD(TInstant deadLine) noexcept {
return TSystemEvent{Ev}.WaitD(deadLine);
- }
-
- /** return true if signaled, false if timed out. */
- inline bool WaitT(TDuration timeOut) noexcept {
+ }
+
+ /** return true if signaled, false if timed out. */
+ inline bool WaitT(TDuration timeOut) noexcept {
return TSystemEvent{Ev}.WaitT(timeOut);
- }
-
- /** Wait infinite time */
- inline void WaitI() noexcept {
+ }
+
+ /** Wait infinite time */
+ inline void WaitI() noexcept {
TSystemEvent{Ev}.WaitI();
- }
-
- /** return true if signaled, false if timed out. */
- inline bool Wait(ui32 timer) noexcept {
+ }
+
+ /** return true if signaled, false if timed out. */
+ inline bool Wait(ui32 timer) noexcept {
return TSystemEvent{Ev}.Wait(timer);
- }
-
- inline bool Wait() noexcept {
+ }
+
+ inline bool Wait() noexcept {
return TSystemEvent{Ev}.Wait();
- }
-
-private:
+ }
+
+private:
TSystemEvent Ev;
-};
+};
diff --git a/util/system/event_ut.cpp b/util/system/event_ut.cpp
index 2506cb7a91..b7167afa8b 100644
--- a/util/system/event_ut.cpp
+++ b/util/system/event_ut.cpp
@@ -5,7 +5,7 @@
#include <util/thread/pool.h>
-namespace {
+namespace {
struct TSharedData {
TSharedData()
: Counter(0)
@@ -14,7 +14,7 @@ namespace {
}
TAtomic Counter;
- TManualEvent event;
+ TManualEvent event;
bool failed;
};
@@ -31,10 +31,10 @@ namespace {
if (Id_ == 0) {
usleep(100);
- bool cond = Data_.Counter == 0;
- if (!cond) {
- Data_.failed = true;
- }
+ bool cond = Data_.Counter == 0;
+ if (!cond) {
+ Data_.failed = true;
+ }
Data_.event.Signal();
} else {
while (!Data_.event.WaitT(TDuration::Seconds(100))) {
@@ -49,50 +49,50 @@ namespace {
};
class TSignalTask: public IObjectInQueue {
- private:
+ private:
TManualEvent& Ev_;
-
- public:
+
+ public:
TSignalTask(TManualEvent& ev)
: Ev_(ev)
- {
- }
-
+ {
+ }
+
void Process(void*) override {
Ev_.Signal();
- }
- };
-
+ }
+ };
+
class TOwnerTask: public IObjectInQueue {
- public:
- TManualEvent Barrier;
- THolder<TManualEvent> Ev;
-
- public:
- TOwnerTask()
- : Ev(new TManualEvent)
- {
- }
-
+ public:
+ TManualEvent Barrier;
+ THolder<TManualEvent> Ev;
+
+ public:
+ TOwnerTask()
+ : Ev(new TManualEvent)
+ {
+ }
+
void Process(void*) override {
- Ev->WaitI();
- Ev.Destroy();
- }
- };
-
+ Ev->WaitI();
+ Ev.Destroy();
+ }
+ };
+
}
-
+
Y_UNIT_TEST_SUITE(EventTest) {
Y_UNIT_TEST(WaitAndSignalTest) {
- TSharedData data;
+ TSharedData data;
TThreadPool queue;
- queue.Start(5);
+ queue.Start(5);
for (size_t i = 0; i < 5; ++i) {
- UNIT_ASSERT(queue.Add(new TThreadTask(data, i)));
+ UNIT_ASSERT(queue.Add(new TThreadTask(data, i)));
}
- queue.Stop();
- UNIT_ASSERT(data.Counter == 10);
- UNIT_ASSERT(!data.failed);
+ queue.Stop();
+ UNIT_ASSERT(data.Counter == 10);
+ UNIT_ASSERT(!data.failed);
}
Y_UNIT_TEST(ConcurrentSignalAndWaitTest) {
@@ -112,21 +112,21 @@ Y_UNIT_TEST_SUITE(EventTest) {
queue.Stop();
}
- /** Test for a problem: http://nga.at.yandex-team.ru/5772 */
+ /** Test for a problem: http://nga.at.yandex-team.ru/5772 */
Y_UNIT_TEST(DestructorBeforeSignalFinishTest) {
return;
TVector<THolder<IObjectInQueue>> tasks;
- for (size_t i = 0; i < 1000; ++i) {
+ for (size_t i = 0; i < 1000; ++i) {
auto owner = MakeHolder<TOwnerTask>();
tasks.emplace_back(MakeHolder<TSignalTask>(*owner->Ev));
tasks.emplace_back(std::move(owner));
- }
+ }
TThreadPool queue;
queue.Start(4);
for (auto& task : tasks) {
- UNIT_ASSERT(queue.Add(task.Get()));
- }
- queue.Stop();
- }
-}
+ UNIT_ASSERT(queue.Add(task.Get()));
+ }
+ queue.Stop();
+ }
+}
diff --git a/util/system/fasttime.cpp b/util/system/fasttime.cpp
index 057a814f0a..e7a293761e 100644
--- a/util/system/fasttime.cpp
+++ b/util/system/fasttime.cpp
@@ -25,10 +25,10 @@ ui64 InterpolatedMicroSeconds() {
#endif
namespace {
- using TTime = ui64;
+ using TTime = ui64;
struct TSymbols {
- using TFunc = int (*)(struct timeval*, struct timezone*);
+ using TFunc = int (*)(struct timeval*, struct timezone*);
inline TSymbols()
: Func(nullptr)
diff --git a/util/system/fstat.cpp b/util/system/fstat.cpp
index 81e98cbc6b..ee333369ec 100644
--- a/util/system/fstat.cpp
+++ b/util/system/fstat.cpp
@@ -36,11 +36,11 @@ ui32 GetFileMode(DWORD fileAttributes) {
#define S_ISREG(st_mode) (st_mode & _S_IFREG)
#define S_ISLNK(st_mode) (st_mode & _S_IFLNK)
-using TSystemFStat = BY_HANDLE_FILE_INFORMATION;
+using TSystemFStat = BY_HANDLE_FILE_INFORMATION;
#else
-using TSystemFStat = struct stat;
+using TSystemFStat = struct stat;
#endif
diff --git a/util/system/hp_timer.h b/util/system/hp_timer.h
index 0a4c252ec2..46f37a8f0b 100644
--- a/util/system/hp_timer.h
+++ b/util/system/hp_timer.h
@@ -3,7 +3,7 @@
#include "defaults.h"
namespace NHPTimer {
- using STime = i64;
+ using STime = i64;
// May delay for ~50ms to compute frequency
double GetSeconds(const STime& a) noexcept;
// Returns the current time
diff --git a/util/system/mutex_ut.cpp b/util/system/mutex_ut.cpp
index c8d7caafa1..cef39de82f 100644
--- a/util/system/mutex_ut.cpp
+++ b/util/system/mutex_ut.cpp
@@ -29,7 +29,7 @@ class TMutexTest: public TTestBase {
class TThreadTask: public IObjectInQueue {
public:
- using PFunc = void (TThreadTask::*)(void);
+ using PFunc = void (TThreadTask::*)(void);
TThreadTask(PFunc func, TSharedData& data, size_t id)
: Func_(func)
diff --git a/util/system/pipe.h b/util/system/pipe.h
index 75d0360049..2e05dac5b0 100644
--- a/util/system/pipe.h
+++ b/util/system/pipe.h
@@ -11,7 +11,7 @@
#include <util/network/pair.h>
#include <util/generic/noncopyable.h>
-using PIPEHANDLE = SOCKET;
+using PIPEHANDLE = SOCKET;
#define INVALID_PIPEHANDLE INVALID_SOCKET
/// Pipe-like object: pipe on POSIX and socket on windows
@@ -81,7 +81,7 @@ public:
private:
class TImpl;
- using TImplRef = TSimpleIntrusivePtr<TImpl>;
+ using TImplRef = TSimpleIntrusivePtr<TImpl>;
TImplRef Impl_;
};
diff --git a/util/system/rwlock_ut.cpp b/util/system/rwlock_ut.cpp
index 2b384c05b3..9bb33af76c 100644
--- a/util/system/rwlock_ut.cpp
+++ b/util/system/rwlock_ut.cpp
@@ -30,7 +30,7 @@ class TRWMutexTest: public TTestBase {
class TThreadTask: public IObjectInQueue {
public:
- using PFunc = void (TThreadTask::*)(void);
+ using PFunc = void (TThreadTask::*)(void);
TThreadTask(PFunc func, TSharedData& data, size_t id, size_t total)
: Func_(func)
diff --git a/util/system/shellcommand.cpp b/util/system/shellcommand.cpp
index b1989b5c8c..65980b6b91 100644
--- a/util/system/shellcommand.cpp
+++ b/util/system/shellcommand.cpp
@@ -25,8 +25,8 @@
#include <sys/wait.h>
using TPid = pid_t;
-using TWaitResult = pid_t;
-using TExitStatus = int;
+using TWaitResult = pid_t;
+using TExitStatus = int;
#define WAIT_PROCEED 0
#if defined(_darwin_)
@@ -40,8 +40,8 @@ using TGetGroupListGid = gid_t;
#include "winint.h"
using TPid = HANDLE;
-using TWaitResult = DWORD;
-using TExitStatus = DWORD;
+using TWaitResult = DWORD;
+using TExitStatus = DWORD;
#define WAIT_PROCEED WAIT_TIMEOUT
#pragma warning(disable : 4296) // 'wait_result >= WAIT_OBJECT_0' : expression is always tru
@@ -182,7 +182,7 @@ private:
};
#else
-using TRealPipeHandle = TPipeHandle;
+using TRealPipeHandle = TPipeHandle;
using REALPIPEHANDLE = PIPEHANDLE;
#define INVALID_REALPIPEHANDLE INVALID_PIPEHANDLE
#endif
diff --git a/util/system/shellcommand.h b/util/system/shellcommand.h
index 8730627fe5..eba960e280 100644
--- a/util/system/shellcommand.h
+++ b/util/system/shellcommand.h
@@ -471,7 +471,7 @@ public:
private:
class TImpl;
- using TImplRef = TSimpleIntrusivePtr<TImpl>;
+ using TImplRef = TSimpleIntrusivePtr<TImpl>;
TImplRef Impl;
};
diff --git a/util/system/sys_alloc.h b/util/system/sys_alloc.h
index 4221a28f8c..3f2ea95116 100644
--- a/util/system/sys_alloc.h
+++ b/util/system/sys_alloc.h
@@ -19,20 +19,20 @@ inline void y_deallocate(void* p) {
free(p);
}
-/**
- * Behavior of realloc from C++99 to C++11 changed (http://www.cplusplus.com/reference/cstdlib/realloc/).
- *
- * Our implementation work as C++99: if new_sz == 0 free will be called on 'p' and nullptr returned.
- */
+/**
+ * Behavior of realloc from C++99 to C++11 changed (http://www.cplusplus.com/reference/cstdlib/realloc/).
+ *
+ * Our implementation work as C++99: if new_sz == 0 free will be called on 'p' and nullptr returned.
+ */
inline void* y_reallocate(void* p, size_t new_sz) {
- if (!new_sz) {
- if (p) {
- free(p);
- }
-
- return nullptr;
- }
-
+ if (!new_sz) {
+ if (p) {
+ free(p);
+ }
+
+ return nullptr;
+ }
+
void* r = realloc(p, new_sz);
if (r == nullptr) {
diff --git a/util/system/thread.cpp b/util/system/thread.cpp
index 6236746c2d..c2286f66bb 100644
--- a/util/system/thread.cpp
+++ b/util/system/thread.cpp
@@ -38,8 +38,8 @@ bool SetHighestThreadPriority() {
}
namespace {
- using TParams = TThread::TParams;
- using TId = TThread::TId;
+ using TParams = TThread::TParams;
+ using TId = TThread::TId;
inline void SetThrName(const TParams& p) {
try {
@@ -71,7 +71,7 @@ namespace {
void* Result;
};
- using TParamsRef = TIntrusivePtr<TMyParams>;
+ using TParamsRef = TIntrusivePtr<TMyParams>;
public:
inline TWinThread(const TParams& params)
@@ -147,7 +147,7 @@ namespace {
#endif
};
- using TThreadBase = TWinThread;
+ using TThreadBase = TWinThread;
#else
//unix
@@ -230,7 +230,7 @@ namespace {
#undef PCHECK
- using TThreadBase = TPosixThread;
+ using TThreadBase = TPosixThread;
#endif
template <class T>
diff --git a/util/system/thread.h b/util/system/thread.h
index a6e8abdb5b..b45670f808 100644
--- a/util/system/thread.h
+++ b/util/system/thread.h
@@ -18,8 +18,8 @@ class TThread {
struct TPrivateCtor {};
public:
- using TThreadProc = void* (*)(void*);
- using TId = size_t;
+ using TThreadProc = void* (*)(void*);
+ using TId = size_t;
struct TParams {
TThreadProc Proc;
diff --git a/util/system/tls.cpp b/util/system/tls.cpp
index c2f1a04a14..330f5a8454 100644
--- a/util/system/tls.cpp
+++ b/util/system/tls.cpp
@@ -23,7 +23,7 @@ namespace {
class TGenericTlsBase {
public:
- using TSmallKey = size_t;
+ using TSmallKey = size_t;
class TPerThreadStorage {
public:
@@ -158,7 +158,7 @@ namespace {
pthread_key_t Key_;
};
- using TKeyDescriptor = TMasterTls::TPerThreadStorage::TKey;
+ using TKeyDescriptor = TMasterTls::TPerThreadStorage::TKey;
}
class TKey::TImpl: public TKeyDescriptor {
diff --git a/util/system/tls.h b/util/system/tls.h
index 3c4f56dbeb..3be71d20b8 100644
--- a/util/system/tls.h
+++ b/util/system/tls.h
@@ -152,7 +152,7 @@ namespace NPrivate {
}
namespace NTls {
- using TDtor = void (*)(void*);
+ using TDtor = void (*)(void*);
class TKey {
public: