Skip to content

Commit

Permalink
ActorSystem memlog use std atomic (#644)
Browse files Browse the repository at this point in the history
  • Loading branch information
kitaisreal authored Dec 26, 2023
1 parent ece919f commit eace4c5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
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

0 comments on commit eace4c5

Please sign in to comment.