改进协程循环逻辑
This commit is contained in:
@@ -590,8 +590,8 @@ void Data_Source_Config::server(Global* g) {
|
||||
HTTP_REQUIRE_VALUE(key, params.try_get_string("key"))
|
||||
HTTP_REQUIRE_VALUE(ds, map.get(key))
|
||||
// 直接关闭
|
||||
ds->enable = false;
|
||||
ds->close();
|
||||
// ds->enable = false;
|
||||
// ds->close();
|
||||
ds->from_json(¶ms);
|
||||
|
||||
g->save();
|
||||
@@ -621,11 +621,8 @@ void Data_Source_Config::server(Global* g) {
|
||||
CHECK_JSON_PARAM
|
||||
HTTP_REQUIRE_VALUE(index, params.try_get_number<int>("index"))
|
||||
HTTP_REQUIRE_VALUE(ds, map.try_get(index))
|
||||
ds->enable = false;
|
||||
ds->close();
|
||||
|
||||
ds->async_stop();
|
||||
HTTP_REQUIRE_TRUE(map.remove(index), "index")
|
||||
|
||||
g->save();
|
||||
res->setBody(warp(to_json()).to_json_string());
|
||||
g->mode_acs.source_feed_relation_config.set_need_refresh();
|
||||
@@ -650,3 +647,21 @@ void Data_Source_Config::server(Global* g) {
|
||||
}
|
||||
|
||||
|
||||
concurrencpp::result<void> Data_Source::loop_coro(
|
||||
std::shared_ptr<concurrencpp::worker_thread_executor> executor_) {
|
||||
auto source = this;
|
||||
co_await concurrencpp::resume_on(executor_);
|
||||
while (enable) {
|
||||
if (!source->running() || !source->registered()) {
|
||||
break;
|
||||
}
|
||||
co_await source->handle_in_loop_coro();
|
||||
auto mode_data = co_await source->read_coro();
|
||||
if (!enable || !source->running() || !source->registered()) {
|
||||
break;
|
||||
}
|
||||
source->process_mode_acs_data(mode_data);
|
||||
co_await concurrencpp::resume_on(executor_);
|
||||
}
|
||||
co_return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user