std::string_view 的使用
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user