std::string_view 的使用

This commit is contained in:
2026-06-29 09:40:55 +08:00
parent ccf7eecc29
commit c25e58ae17
40 changed files with 532 additions and 522 deletions
+6 -5
View File
@@ -1,4 +1,5 @@
#pragma once
#include <string_view>
#include "Core/Statistics/Frequency_Limit.h"
#include <atomic>
@@ -12,7 +13,7 @@
struct Detach_Thread {
explicit Detach_Thread(
const std::string &name,
std::string_view name,
const std::function<void(std::atomic<bool> &running)> &func);
void start();
std::string name;
@@ -23,9 +24,9 @@ struct Detach_Thread {
struct Detach_Thread_Manager {
Detach_Thread_Manager() = default;
void test_and_start_thread(
const std::string &name,
std::string_view name,
const std::function<void(std::atomic<bool> &running)> &func);
void test_and_stop_thread(const std::string &name);
void test_and_stop_thread(std::string_view name);
void stop_all_thread(size_t timeout_milliseconds = 10000,
std::set<std::string> excluded_thread = {});
Detach_Thread *get_thread(const std::thread::id thread_id);
@@ -33,8 +34,8 @@ struct Detach_Thread_Manager {
protected:
Frequency_Limit fl;
std::map<std::string, Detach_Thread *> thread_map;
void exit_thread(const std::string &name);
void start_thread(const std::string &name,
void exit_thread(std::string_view name);
void start_thread(std::string_view name,
const std::function<void(std::atomic<bool> &)> &f);
std::chrono::time_point<std::chrono::high_resolution_clock> exit_time;
};