协程调度器,重大更新
This commit is contained in:
@@ -79,8 +79,8 @@ std::string Data_Source::thread_key() const {
|
||||
}
|
||||
|
||||
void Data_Source::test_and_attach_thread() {
|
||||
if (enable) {
|
||||
open();
|
||||
if (enable && open()) {
|
||||
data_source_loop_requested_.store(true, std::memory_order_release);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,8 +109,30 @@ void File_Data_Source::before_handle_msg(std::shared_ptr<SSR::Mode_Msg>& msg) {
|
||||
|
||||
|
||||
|
||||
void Data_Source::test_and_stop_thread() const {
|
||||
Global::instance()->thread_manager.test_and_stop_thread(thread_key());
|
||||
void Data_Source::test_and_stop_thread() {
|
||||
data_source_loop_requested_.store(false, std::memory_order_release);
|
||||
data_source_loop_generation_.fetch_add(1, std::memory_order_acq_rel);
|
||||
}
|
||||
|
||||
bool Data_Source::data_source_loop_should_run() const {
|
||||
return data_source_loop_requested_.load(std::memory_order_acquire);
|
||||
}
|
||||
|
||||
std::uint64_t Data_Source::data_source_loop_generation() const {
|
||||
return data_source_loop_generation_.load(std::memory_order_acquire);
|
||||
}
|
||||
|
||||
bool Data_Source::try_mark_data_source_loop_running() {
|
||||
bool expected = false;
|
||||
return data_source_loop_running_.compare_exchange_strong(
|
||||
expected,
|
||||
true,
|
||||
std::memory_order_acq_rel,
|
||||
std::memory_order_acquire);
|
||||
}
|
||||
|
||||
void Data_Source::mark_data_source_loop_stopped() {
|
||||
data_source_loop_running_.store(false, std::memory_order_release);
|
||||
}
|
||||
|
||||
|
||||
@@ -603,14 +625,12 @@ void Data_Source_Config::server(Global* g) {
|
||||
HTTP_REQUIRE_VALUE(key, params.try_get_string("key"))
|
||||
HTTP_REQUIRE_VALUE(ds, map.get(key))
|
||||
// 直接关闭
|
||||
ds->test_and_stop_thread();
|
||||
ds->close();
|
||||
ds->from_json(¶ms);
|
||||
if (ds->enable) {
|
||||
ds->open();
|
||||
ds->test_and_attach_thread();
|
||||
} else
|
||||
{
|
||||
ds->test_and_stop_thread();
|
||||
}
|
||||
g->save();
|
||||
g->mode_acs.source_feed_relation_config.set_need_refresh();
|
||||
@@ -642,8 +662,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->close();
|
||||
ds->test_and_stop_thread();
|
||||
ds->close();
|
||||
|
||||
HTTP_REQUIRE_TRUE(map.remove(index), "index")
|
||||
g->save();
|
||||
|
||||
Reference in New Issue
Block a user