重新设置代码格式
This commit is contained in:
+24
-19
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "Core/Statistics/Frequency_Limit.h"
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
#include <functional>
|
||||
@@ -9,27 +9,32 @@
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include "Core/Statistics/Frequency_Limit.h"
|
||||
|
||||
|
||||
struct Detach_Thread {
|
||||
explicit Detach_Thread(const std::string& name, const std::function<void(std::atomic<bool>& running)>& func);
|
||||
void start();
|
||||
std::string name;
|
||||
std::thread thread;
|
||||
std::atomic<bool> running = true; //控制运行
|
||||
std::atomic<bool> exit = false;
|
||||
explicit Detach_Thread(
|
||||
const std::string &name,
|
||||
const std::function<void(std::atomic<bool> &running)> &func);
|
||||
void start();
|
||||
std::string name;
|
||||
std::thread thread;
|
||||
std::atomic<bool> running = true; // 控制运行
|
||||
std::atomic<bool> exit = false;
|
||||
};
|
||||
struct Detach_Thread_Manager {
|
||||
Detach_Thread_Manager() = default;
|
||||
void test_and_start_thread(const std::string& name, const std::function<void(std::atomic<bool>& running)>& func);
|
||||
void test_and_stop_thread(const std::string& 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);
|
||||
Detach_Thread_Manager() = default;
|
||||
void test_and_start_thread(
|
||||
const std::string &name,
|
||||
const std::function<void(std::atomic<bool> &running)> &func);
|
||||
void test_and_stop_thread(const std::string &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);
|
||||
|
||||
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, const std::function<void(std::atomic<bool> &)> &f);
|
||||
std::chrono::time_point<std::chrono::high_resolution_clock> exit_time;
|
||||
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,
|
||||
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