Skip to content

Commit

Permalink
Fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Gazizonoki committed Mar 7, 2024
1 parent 7d67143 commit 350163f
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 13 deletions.
4 changes: 2 additions & 2 deletions library/cpp/logger/sync_page_cache_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class TSyncPageCacheFileLogBackend::TImpl: public TNonCopyable {
}

void WriteData(const TLogRecord& rec) {
TGuard guard{Lock_};
std::lock_guard guard{Lock_};

Buffer_.Append(rec.Data, rec.Len);
if (Buffer_.size() >= MaxBufferSize_) {
Expand All @@ -48,7 +48,7 @@ class TSyncPageCacheFileLogBackend::TImpl: public TNonCopyable {
}

void ReopenLog() {
TGuard guard{Lock_};
std::lock_guard guard{Lock_};

Write();
FlushSync(GuaranteedWrittenPtr_, WrittenPtr_);
Expand Down
5 changes: 3 additions & 2 deletions library/cpp/monlib/counters/counters.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <util/system/spinlock.h>

#include <map>
#include <mutex>
#include <array>

namespace NMonitoring {
Expand Down Expand Up @@ -259,7 +260,7 @@ namespace NMonitoring {

private:
G* Add(const T& name) {
TGuard<TSpinLock> guard(AddMutex);
std::lock_guard guard(AddMutex);
G* result = Groups->Find(name);
if (result == nullptr) {
T* newName = new T(name);
Expand Down Expand Up @@ -293,7 +294,7 @@ namespace NMonitoring {
}

virtual ~TDeprecatedCounterGroups() {
TGuard<TSpinLock> guard(AddMutex);
std::lock_guard guard(AddMutex);
Groups->Free();
delete Groups;
Groups = nullptr;
Expand Down
4 changes: 3 additions & 1 deletion library/cpp/testing/common/env.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include <library/cpp/json/json_value.h>
#include <library/cpp/json/json_writer.h>

#include <mutex>

std::string ArcadiaSourceRoot() {
if (const auto& sourceRoot = NPrivate::GetTestEnv().SourceRoot) {
return sourceRoot;
Expand Down Expand Up @@ -116,7 +118,7 @@ const std::string& GetGlobalResource(std::string_view name) {

void AddEntryToCoreSearchFile(const std::string& filename, std::string_view cmd, int pid, const TFsPath& binaryPath = TFsPath(), const TFsPath& cwd = TFsPath()) {
auto lock = TFileLock(filename);
TGuard<TFileLock> guard(lock);
std::lock_guard guard(lock);

TOFStream output(TFile(filename, WrOnly | ForAppend | OpenAlways));

Expand Down
4 changes: 2 additions & 2 deletions library/cpp/threading/future/wait/wait_group-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ namespace NThreading {
std::exception_ptr ExceptionInFlight;

void TrySetException(std::exception_ptr eptr) noexcept {
TGuard lock{Mut};
std::lock_guard lock{Mut};
if (!ExceptionInFlight) {
ExceptionInFlight = std::move(eptr);
}
}

std::exception_ptr GetExceptionInFlight() const noexcept {
TGuard lock{Mut};
std::lock_guard lock{Mut};
return ExceptionInFlight;
}
};
Expand Down
12 changes: 7 additions & 5 deletions util/system/flock_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

#include <library/cpp/testing/unittest/registar.h>

#include <mutex>

Y_UNIT_TEST_SUITE(TFileLockTest) {
Y_UNIT_TEST(TestFlock) {
TTempFileHandle tmp("./file");
Expand All @@ -21,33 +23,33 @@ Y_UNIT_TEST_SUITE(TFileLockTest) {
TFileLock fileLockShared2("./file.locker", EFileLockType::Shared);
TFileLock fileLockShared3("./file.locker", EFileLockType::Shared);
{
TGuard<TFileLock> guard(fileLockExclusive1);
std::lock_guard guard(fileLockExclusive1);
}
{
TTryGuard<TFileLock> tryGuard(fileLockExclusive1);
UNIT_ASSERT(tryGuard.WasAcquired());
}
{
TGuard<TFileLock> guard1(fileLockExclusive1);
std::lock_guard guard1(fileLockExclusive1);
TTryGuard<TFileLock> guard2(fileLockExclusive2);
UNIT_ASSERT(!guard2.WasAcquired());
}
{
TGuard<TFileLock> guard1(fileLockShared1);
std::lock_guard guard1(fileLockShared1);
TTryGuard<TFileLock> guard2(fileLockShared2);
TTryGuard<TFileLock> guard3(fileLockShared3);
UNIT_ASSERT(guard2.WasAcquired());
UNIT_ASSERT(guard3.WasAcquired());
}
{
TGuard<TFileLock> guard1(fileLockExclusive1);
std::lock_guard guard1(fileLockExclusive1);
TTryGuard<TFileLock> guard2(fileLockShared1);
TTryGuard<TFileLock> guard3(fileLockShared2);
UNIT_ASSERT(!guard2.WasAcquired());
UNIT_ASSERT(!guard3.WasAcquired());
}
{
TGuard<TFileLock> guard1(fileLockShared1);
std::lock_guard guard1(fileLockShared1);
TTryGuard<TFileLock> guard2(fileLockExclusive1);
TTryGuard<TFileLock> guard3(fileLockShared2);
UNIT_ASSERT(!guard2.WasAcquired());
Expand Down
2 changes: 1 addition & 1 deletion util/thread/pool_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct TThreadPoolTest {
void Process(void*) override {
THolder<TTask> This(this);

TGuard<TSpinLock> guard(Test->Lock);
std::lock_guard guard(Test->Lock);
Test->R ^= Value;
}
};
Expand Down

0 comments on commit 350163f

Please sign in to comment.