改进协程循环逻辑2
This commit is contained in:
@@ -348,23 +348,21 @@ std::string get_true_from_raw_line(Data_Source* ds, File_Data_Type data_type, in
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void File_Data_Source::_close() {
|
||||
concurrencpp::result<void> File_Data_Source::_close() {
|
||||
std::lock_guard g(mtx);
|
||||
index = 0;
|
||||
part_infos.clear();
|
||||
co_return;
|
||||
}
|
||||
|
||||
bool File_Data_Source::_open() {
|
||||
concurrencpp::result<void> File_Data_Source::_open() {
|
||||
std::lock_guard g(mtx);
|
||||
auto path = get_true_file_path();
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
if (!fs::exists(path)) {
|
||||
state = "文件不存在";
|
||||
return false;
|
||||
co_return;
|
||||
}
|
||||
|
||||
if (data_type == File_Data_Type::BIN) {
|
||||
@@ -374,7 +372,7 @@ bool File_Data_Source::_open() {
|
||||
part_infos = readLines(path);
|
||||
}
|
||||
state = "已加载" + to_string(part_infos.size()) + "长度数据!";
|
||||
return true;
|
||||
co_return;
|
||||
}
|
||||
|
||||
|
||||
@@ -517,14 +515,14 @@ void Dll_Data_Source::origin_data_transform_mode_data(std::string& mode_data)
|
||||
mode_data = ret;
|
||||
}
|
||||
|
||||
|
||||
bool Shared_Memory_Data_Source::_open() {
|
||||
concurrencpp::result<void> Shared_Memory_Data_Source::_open() {
|
||||
sm = std::make_unique<Psc::SM_RingBuffer>();
|
||||
sm->init(shared_memory_name, shared_memory_size);
|
||||
return true;
|
||||
co_return;
|
||||
}
|
||||
void Shared_Memory_Data_Source::_close() {
|
||||
concurrencpp::result<void> Shared_Memory_Data_Source::_close() {
|
||||
sm.reset();
|
||||
co_return;
|
||||
}
|
||||
|
||||
void Shared_Memory_Data_Source::origin_data_transform_mode_data(std::string& mode_data)
|
||||
|
||||
Reference in New Issue
Block a user