Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class Logger {
Args &&...args) {
// During process/library teardown this logger's owned sinks may already
// have been destroyed. Use a temporary stack sink instead.
if (isTearDowned) {
if (isTearDowned.load(std::memory_order_acquire)) {
if (!isLegacySink && level < this->standardSinkLevel) {
return;
}
Expand Down
7 changes: 4 additions & 3 deletions unified-runtime/source/common/logger/ur_sinks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#ifndef UR_SINKS_HPP
#define UR_SINKS_HPP 1

#include <atomic>
#include <fstream>
#include <functional>
#include <iostream>
Expand All @@ -19,7 +20,7 @@

namespace logger {

inline bool isTearDowned = false;
inline std::atomic<bool> isTearDowned = false;

class Sink {
public:
Expand Down Expand Up @@ -48,7 +49,7 @@ class Sink {
// the UR adapter.
// TODO: Change adapters to use a common sink class in the loader instead of
// using thier own sink class that inherit from logger::Sink.
if (isTearDowned) {
if (isTearDowned.load(std::memory_order_acquire)) {
std::cerr << message;
} else {
print(level, message);
Expand Down Expand Up @@ -186,7 +187,7 @@ class StderrSink : public Sink {
this->flush_level = flush_lvl;
}

~StderrSink() { logger::isTearDowned = true; }
~StderrSink() { logger::isTearDowned.store(true, std::memory_order_release); }
};

class FileSink : public Sink {
Expand Down
Loading