提交 39b31907 编写于 作者: A Alexey Milovidov

Rename function #7477

上级 f9eb4e79
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include <Common/TaskStatsInfoGetter.h> #include <Common/TaskStatsInfoGetter.h>
#include <Interpreters/ProcessList.h> #include <Interpreters/ProcessList.h>
#include <Interpreters/Context.h> #include <Interpreters/Context.h>
#include <common/getThreadNumber.h> #include <common/getThreadId.h>
#include <Poco/Logger.h> #include <Poco/Logger.h>
...@@ -34,7 +34,7 @@ bool CurrentThread::isInitialized() ...@@ -34,7 +34,7 @@ bool CurrentThread::isInitialized()
ThreadStatus & CurrentThread::get() ThreadStatus & CurrentThread::get()
{ {
if (unlikely(!current_thread)) if (unlikely(!current_thread))
throw Exception("Thread #" + std::to_string(getThreadNumber()) + " status was not initialized", ErrorCodes::LOGICAL_ERROR); throw Exception("Thread #" + std::to_string(getThreadId()) + " status was not initialized", ErrorCodes::LOGICAL_ERROR);
return *current_thread; return *current_thread;
} }
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include <Common/ThreadStatus.h> #include <Common/ThreadStatus.h>
#include <Poco/Logger.h> #include <Poco/Logger.h>
#include <common/getThreadNumber.h> #include <common/getThreadId.h>
namespace DB namespace DB
...@@ -34,7 +34,7 @@ TasksStatsCounters TasksStatsCounters::current() ...@@ -34,7 +34,7 @@ TasksStatsCounters TasksStatsCounters::current()
ThreadStatus::ThreadStatus() ThreadStatus::ThreadStatus()
{ {
thread_id = getThreadNumber(); thread_id = getThreadId();
last_rusage = std::make_unique<RUsageCounters>(); last_rusage = std::make_unique<RUsageCounters>();
last_taskstats = std::make_unique<TasksStatsCounters>(); last_taskstats = std::make_unique<TasksStatsCounters>();
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include <Common/TaskStatsInfoGetter.h> #include <Common/TaskStatsInfoGetter.h>
#include <Poco/File.h> #include <Poco/File.h>
#include <Common/Stopwatch.h> #include <Common/Stopwatch.h>
#include <common/getThreadNumber.h> #include <common/getThreadId.h>
#include <IO/WriteBufferFromString.h> #include <IO/WriteBufferFromString.h>
#include <linux/taskstats.h> #include <linux/taskstats.h>
#include <sys/time.h> #include <sys/time.h>
...@@ -48,7 +48,7 @@ using namespace DB; ...@@ -48,7 +48,7 @@ using namespace DB;
static void do_io(size_t id) static void do_io(size_t id)
{ {
::taskstats stat; ::taskstats stat;
int tid = getThreadNumber(); int tid = getThreadId();
TaskStatsInfoGetter get_info; TaskStatsInfoGetter get_info;
get_info.getStat(stat, tid); get_info.getStat(stat, tid);
...@@ -104,7 +104,7 @@ static void test_perf() ...@@ -104,7 +104,7 @@ static void test_perf()
{ {
::taskstats stat; ::taskstats stat;
int tid = getThreadNumber(); int tid = getThreadId();
TaskStatsInfoGetter get_info; TaskStatsInfoGetter get_info;
rusage rusage; rusage rusage;
......
#include <Storages/MergeTree/MergeList.h> #include <Storages/MergeTree/MergeList.h>
#include <Storages/MergeTree/MergeTreeDataMergerMutator.h> #include <Storages/MergeTree/MergeTreeDataMergerMutator.h>
#include <Common/CurrentMetrics.h> #include <Common/CurrentMetrics.h>
#include <common/getThreadNumber.h> #include <common/getThreadId.h>
#include <Common/CurrentThread.h> #include <Common/CurrentThread.h>
...@@ -20,7 +20,7 @@ MergeListElement::MergeListElement(const std::string & database_, const std::str ...@@ -20,7 +20,7 @@ MergeListElement::MergeListElement(const std::string & database_, const std::str
, result_part_path{future_part.path} , result_part_path{future_part.path}
, result_data_version{future_part.part_info.getDataVersion()} , result_data_version{future_part.part_info.getDataVersion()}
, num_parts{future_part.parts.size()} , num_parts{future_part.parts.size()}
, thread_id{getThreadNumber()} , thread_id{getThreadId()}
{ {
for (const auto & source_part : future_part.parts) for (const auto & source_part : future_part.parts)
{ {
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include <Common/typeid_cast.h> #include <Common/typeid_cast.h>
#include <Common/ProfileEvents.h> #include <Common/ProfileEvents.h>
#include <common/logger_useful.h> #include <common/logger_useful.h>
#include <common/getThreadNumber.h> #include <common/getThreadId.h>
#include <ext/range.h> #include <ext/range.h>
#include <DataStreams/FilterBlockInputStream.h> #include <DataStreams/FilterBlockInputStream.h>
#include <DataStreams/ExpressionBlockInputStream.h> #include <DataStreams/ExpressionBlockInputStream.h>
...@@ -387,7 +387,7 @@ public: ...@@ -387,7 +387,7 @@ public:
} }
/// We distribute the load on the shards by the stream number. /// We distribute the load on the shards by the stream number.
const auto start_shard_num = getThreadNumber() % storage.num_shards; const auto start_shard_num = getThreadId() % storage.num_shards;
/// We loop through the buffers, trying to lock mutex. No more than one lap. /// We loop through the buffers, trying to lock mutex. No more than one lap.
auto shard_num = start_shard_num; auto shard_num = start_shard_num;
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include <DataTypes/DataTypeArray.h> #include <DataTypes/DataTypeArray.h>
#include <IO/ReadHelpers.h> #include <IO/ReadHelpers.h>
#include <Common/PipeFDs.h> #include <Common/PipeFDs.h>
#include <common/getThreadNumber.h> #include <common/getThreadId.h>
namespace DB namespace DB
......
#pragma once
/// Obtain thread id from OS. The value is cached in thread local variable.
unsigned getThreadId();
#pragma once #pragma once
#include "demangle.h" #include "demangle.h"
#include "getThreadNumber.h" #include "getThreadId.h"
#include <type_traits> #include <type_traits>
#include <tuple> #include <tuple>
#include <iomanip> #include <iomanip>
...@@ -141,7 +141,7 @@ Out & dump(Out & out, const char * name, T && x) ...@@ -141,7 +141,7 @@ Out & dump(Out & out, const char * name, T && x)
#endif #endif
#define DUMPVAR(VAR) ::dump(std::cerr, #VAR, (VAR)); std::cerr << "; "; #define DUMPVAR(VAR) ::dump(std::cerr, #VAR, (VAR)); std::cerr << "; ";
#define DUMPHEAD std::cerr << __FILE__ << ':' << __LINE__ << " [ " << getThreadNumber() << " ] "; #define DUMPHEAD std::cerr << __FILE__ << ':' << __LINE__ << " [ " << getThreadId() << " ] ";
#define DUMPTAIL std::cerr << '\n'; #define DUMPTAIL std::cerr << '\n';
#define DUMP1(V1) do { DUMPHEAD DUMPVAR(V1) DUMPTAIL } while(0) #define DUMP1(V1) do { DUMPHEAD DUMPVAR(V1) DUMPTAIL } while(0)
......
#include <unistd.h>
#include <syscall.h>
static thread_local unsigned current_tid = 0;
unsigned getThreadId()
{
if (!current_tid)
current_tid = syscall(SYS_gettid); /// This call is always successful. - man gettid
return current_tid;
}
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#include <Poco/Version.h> #include <Poco/Version.h>
#include <common/Types.h> #include <common/Types.h>
#include <common/logger_useful.h> #include <common/logger_useful.h>
#include <common/getThreadNumber.h> #include <common/getThreadId.h>
#include <daemon/GraphiteWriter.h> #include <daemon/GraphiteWriter.h>
#include <Common/Config/ConfigProcessor.h> #include <Common/Config/ConfigProcessor.h>
#include <loggers/Loggers.h> #include <loggers/Loggers.h>
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
#include <common/logger_useful.h> #include <common/logger_useful.h>
#include <common/ErrorHandlers.h> #include <common/ErrorHandlers.h>
#include <common/argsToConfig.h> #include <common/argsToConfig.h>
#include <common/getThreadNumber.h> #include <common/getThreadId.h>
#include <common/coverage.h> #include <common/coverage.h>
#include <IO/WriteBufferFromFile.h> #include <IO/WriteBufferFromFile.h>
...@@ -123,7 +123,7 @@ static void signalHandler(int sig, siginfo_t * info, void * context) ...@@ -123,7 +123,7 @@ static void signalHandler(int sig, siginfo_t * info, void * context)
DB::writePODBinary(*info, out); DB::writePODBinary(*info, out);
DB::writePODBinary(signal_context, out); DB::writePODBinary(signal_context, out);
DB::writePODBinary(stack_trace, out); DB::writePODBinary(stack_trace, out);
DB::writeBinary(UInt32(getThreadNumber()), out); DB::writeBinary(UInt32(getThreadId()), out);
DB::writeStringBinary(query_id, out); DB::writeStringBinary(query_id, out);
out.next(); out.next();
...@@ -301,7 +301,7 @@ static void terminate_handler() ...@@ -301,7 +301,7 @@ static void terminate_handler()
DB::WriteBufferFromFileDescriptor out(signal_pipe.fds_rw[1], buf_size, buf); DB::WriteBufferFromFileDescriptor out(signal_pipe.fds_rw[1], buf_size, buf);
DB::writeBinary(static_cast<int>(SignalListener::StdTerminate), out); DB::writeBinary(static_cast<int>(SignalListener::StdTerminate), out);
DB::writeBinary(UInt32(getThreadNumber()), out); DB::writeBinary(UInt32(getThreadId()), out);
DB::writeBinary(log_message, out); DB::writeBinary(log_message, out);
out.next(); out.next();
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
#include <sys/time.h> #include <sys/time.h>
#include <Common/CurrentThread.h> #include <Common/CurrentThread.h>
#include <Common/Exception.h> #include <Common/Exception.h>
#include <common/getThreadNumber.h> #include <common/getThreadId.h>
namespace DB namespace DB
...@@ -31,7 +31,7 @@ ExtendedLogMessage ExtendedLogMessage::getFrom(const Poco::Message & base) ...@@ -31,7 +31,7 @@ ExtendedLogMessage ExtendedLogMessage::getFrom(const Poco::Message & base)
msg_ext.query_id.assign(query_id_ref.data, query_id_ref.size); msg_ext.query_id.assign(query_id_ref.data, query_id_ref.size);
} }
msg_ext.thread_id = getThreadNumber(); msg_ext.thread_id = getThreadId();
return msg_ext; return msg_ext;
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include <Interpreters/InternalTextLogsQueue.h> #include <Interpreters/InternalTextLogsQueue.h>
#include <sys/time.h> #include <sys/time.h>
#include <Common/CurrentThread.h> #include <Common/CurrentThread.h>
#include <common/getThreadNumber.h> #include <common/getThreadId.h>
#include "Loggers.h" #include "Loggers.h"
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include <Poco/Message.h> #include <Poco/Message.h>
#include <Common/CurrentThread.h> #include <Common/CurrentThread.h>
#include <Common/DNSResolver.h> #include <Common/DNSResolver.h>
#include <common/getThreadNumber.h> #include <common/getThreadId.h>
#include <Common/SensitiveDataMasker.h> #include <Common/SensitiveDataMasker.h>
namespace DB namespace DB
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册