改进协程循环逻辑

This commit is contained in:
2026-06-25 15:01:29 +08:00
parent 03bfac8d0c
commit 1504db9db0
12 changed files with 409 additions and 484 deletions
+4 -23
View File
@@ -1,6 +1,7 @@
#pragma once
#include "global.h"
#include "Local_Server/server/With_Loop_Coro.h"
enum class Output_Data_Format {
AVR,
@@ -44,16 +45,13 @@ struct Output_Format {
};
class Data_Feed {
class Data_Feed : public With_Loop_Coro {
public:
virtual ~Data_Feed() = default;
std::unique_ptr<concurrencpp::result<void>> loop_task;
BIN_Msg_Buffer msg_buffer{};
std::string key;
bool enable = false;
std::string type;
Output_Format output_format;
Frequency_Limit_Multi sbs_flm{};
concurrencpp::result<void> loop_coro(std::shared_ptr<concurrencpp::worker_thread_executor> executor) override;
virtual void handle_in_loop() {
}
@@ -86,17 +84,7 @@ public:
ret.append_list(get_custom_state_json().children);
return ret;
}
bool check_and_open() {
if (_open_) return true;
bool ret = _open();
_open_ = true;
return ret;
}
void close() {
_open_ = false;
_close();
}
std::string to_string() {
return "Data_Feed{" + VAR_STR_3(key, enable, type) + "}";
@@ -105,14 +93,7 @@ public:
bool registered();
protected:
Data_Feed() = default;
bool _open_ = false;
virtual bool _open() {
return true;
}
virtual void _close() {
}
Frequency_Limit too_many_msg_limit;
};