Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ydb/library/actors/memory_log/memlog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ unsigned TMemoryLog::GetSelfCpu() noexcept {
#endif
}

TMemoryLog* TMemoryLog::MemLogBuffer = nullptr;
std::atomic<TMemoryLog*> TMemoryLog::MemLogBuffer = nullptr;
Y_POD_THREAD(TThread::TId)
TMemoryLog::LogThreadId;
char* TMemoryLog::LastMarkIsHere = nullptr;
Expand Down
8 changes: 4 additions & 4 deletions ydb/library/actors/memory_log/memlog.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class TMemoryLog {
static constexpr size_t LAST_MARK_SIZE = sizeof(DEFAULT_LAST_MARK);

inline static TMemoryLog* GetMemoryLogger() noexcept {
return AtomicGet(MemLogBuffer);
return MemLogBuffer.load(std::memory_order_acquire);
}

void* GetWriteBuffer(size_t amount) noexcept;
Expand All @@ -63,11 +63,11 @@ class TMemoryLog {
size_t totalSize = DEFAULT_TOTAL_SIZE,
size_t grainSize = DEFAULT_GRAIN_SIZE)
Y_COLD {
if (AtomicGet(MemLogBuffer) != nullptr) {
if (MemLogBuffer.load(std::memory_order_acquire) != nullptr) {
return;
}

AtomicSet(MemLogBuffer, new TMemoryLog(totalSize, grainSize));
MemLogBuffer.store(new TMemoryLog(totalSize, grainSize), std::memory_order_release);
}

static std::atomic<bool> PrintLastMark;
Expand Down Expand Up @@ -163,7 +163,7 @@ class TMemoryLog {

static unsigned GetSelfCpu() noexcept;

static TMemoryLog* MemLogBuffer;
static std::atomic<TMemoryLog*> MemLogBuffer;
static Y_POD_THREAD(TThread::TId) LogThreadId;
static char* LastMarkIsHere;
};
Expand Down