Remove mutex

This commit is contained in:
Dmitry Kardymon 2023-07-13 08:15:50 +00:00
parent 3649f10444
commit 220c0255ab
4 changed files with 7 additions and 12 deletions

View File

@ -72,7 +72,6 @@ template <typename LogElement>
void SystemLogBase<LogElement>::startup()
{
std::lock_guard lock(queue->mutex);
std::cout << "void ISystemLog::startup()" << std::endl;
saving_thread = std::make_unique<ThreadFromGlobalPool>([this] { savingThreadFunction(); });
}

View File

@ -37,7 +37,6 @@ static std::string createDirectory(const std::string & file)
void Loggers::buildLoggers(Poco::Util::AbstractConfiguration & config, Poco::Logger & logger /*_root*/, const std::string & cmd_name)
{
auto current_logger = config.getString("logger", "");
if (config_logger.has_value() && *config_logger == current_logger)
return;
@ -51,9 +50,12 @@ void Loggers::buildLoggers(Poco::Util::AbstractConfiguration & config, Poco::Log
split = new DB::OwnSplitChannel();
#ifndef WITHOUT_TEXT_LOG
String text_log_level_str = config.getString("text_log.level", "");
int text_log_level = text_log_level_str.empty() ? INT_MAX : Poco::Logger::parseLevel(text_log_level_str);
split->addTextLog(DB::TextLog::getLogQueue(), text_log_level);
if (config.has("text_log"))
{
String text_log_level_str = config.getString("text_log.level", "");
int text_log_level = text_log_level_str.empty() ? INT_MAX : Poco::Logger::parseLevel(text_log_level_str);
split->addTextLog(DB::TextLog::getLogQueue(), text_log_level);
}
#endif
auto log_level_string = config.getString("logger.level", "trace");

View File

@ -136,10 +136,7 @@ void OwnSplitChannel::logSplit(const Poco::Message & msg)
elem.message_format_string = msg.getFormatString();
std::shared_ptr<SystemLogQueue<TextLogElement>> text_log_locked{};
{
std::lock_guard lock(text_log_mutex);
text_log_locked = text_log.lock();
}
text_log_locked = text_log.lock();
if (text_log_locked)
text_log_locked->add(elem);
}
@ -155,7 +152,6 @@ void OwnSplitChannel::addChannel(Poco::AutoPtr<Poco::Channel> channel, const std
#ifndef WITHOUT_TEXT_LOG
void OwnSplitChannel::addTextLog(std::shared_ptr<SystemLogQueue<TextLogElement>> log_queue, int max_priority)
{
std::lock_guard lock(text_log_mutex);
text_log = log_queue;
text_log_max_priority.store(max_priority, std::memory_order_relaxed);
}

View File

@ -47,8 +47,6 @@ private:
using ExtendedChannelPtrPair = std::pair<ChannelPtr, ExtendedLogChannel *>;
std::map<std::string, ExtendedChannelPtrPair> channels;
std::mutex text_log_mutex;
#ifndef WITHOUT_TEXT_LOG
std::weak_ptr<DB::FooBar> text_log;
std::atomic<int> text_log_max_priority = -1;