Added some thread names
This commit is contained in:
@@ -244,7 +244,7 @@ namespace Scanner
|
||||
|
||||
ScanStepScanFiles::MetadataScanQueue::MetadataScanQueue(MetaData::IParser& parser, std::size_t threadCount, bool& abort)
|
||||
: _metadataParser{ parser }
|
||||
, _scanContextRunner{ _scanContext, threadCount }
|
||||
, _scanContextRunner{ _scanContext, threadCount, "ScannerMetadata" }
|
||||
, _abort{ abort }
|
||||
{}
|
||||
|
||||
|
||||
@@ -22,16 +22,31 @@
|
||||
#include <cstdlib>
|
||||
|
||||
#include "utils/ILogger.hpp"
|
||||
#include "utils/IProfiler.hpp"
|
||||
|
||||
IOContextRunner::IOContextRunner(boost::asio::io_service& ioService, std::size_t threadCount)
|
||||
IOContextRunner::IOContextRunner(boost::asio::io_service& ioService, std::size_t threadCount, std::string_view name)
|
||||
: _ioService{ ioService }
|
||||
, _work{ ioService }
|
||||
{
|
||||
LMS_LOG(UTILS, INFO, "Starting IO context with " << threadCount << " threads...");
|
||||
|
||||
for (std::size_t i{}; i < threadCount; ++i)
|
||||
{
|
||||
_threads.emplace_back([&]
|
||||
std::string threadName{ name };
|
||||
if (!threadName.empty())
|
||||
{
|
||||
threadName += "Thread_";
|
||||
threadName += std::to_string(i);
|
||||
}
|
||||
|
||||
_threads.emplace_back([this, threadName]
|
||||
{
|
||||
if (!threadName.empty())
|
||||
{
|
||||
if (auto * profiler{ Service<profiling::IProfiler>::get() })
|
||||
profiler->setThreadName(std::this_thread::get_id(), threadName);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_ioService.run();
|
||||
@@ -45,8 +60,7 @@ IOContextRunner::IOContextRunner(boost::asio::io_service& ioService, std::size_t
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
IOContextRunner::stop()
|
||||
void IOContextRunner::stop()
|
||||
{
|
||||
LMS_LOG(UTILS, DEBUG, "Stopping IO context...");
|
||||
_work.reset();
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
class IOContextRunner
|
||||
{
|
||||
public:
|
||||
IOContextRunner(boost::asio::io_service& ioService, std::size_t threadCount);
|
||||
IOContextRunner(boost::asio::io_service& ioService, std::size_t threadCount, std::string_view name);
|
||||
~IOContextRunner();
|
||||
|
||||
void stop();
|
||||
|
||||
+1
-1
@@ -277,7 +277,7 @@ int main(int argc, char* argv[])
|
||||
Wt::WServer server{ argv[0] };
|
||||
server.setServerConfiguration(wtServerArgs.size(), const_cast<char**>(&wtArgv[0]));
|
||||
|
||||
IOContextRunner ioContextRunner{ ioContext, getThreadCount() };
|
||||
IOContextRunner ioContextRunner{ ioContext, getThreadCount(), "Misc" };
|
||||
|
||||
// Connection pool size must be twice the number of threads: we have at least 2 io pools with getThreadCount() each and they all may access the database
|
||||
Database::Db database{ config->getPath("working-dir") / "lms.db", getThreadCount() * 2 };
|
||||
|
||||
Reference in New Issue
Block a user