ENH: cli: refine the progress logic

update 1% at the very beginning

Change-Id: I85e19ad5c8ed4b8465510ffb3db4fac12c0f20b9
(cherry picked from commit 5d4ca3be8e6af2c66ecd5d51fead3e7ca5ffa7f5)
This commit is contained in:
lane.wei 2023-05-24 19:56:45 +08:00 committed by Lane.Wei
parent 839f4fe85e
commit 84b89094b2

View file

@ -198,6 +198,7 @@ typedef struct _cli_callback_mgr {
m_data_ready = false; m_data_ready = false;
lck.unlock(); lck.unlock();
m_condition.notify_one(); m_condition.notify_one();
boost::this_thread::sleep(boost::posix_time::milliseconds(20));
BOOST_LOG_TRIVIAL(info) << "cli_callback_mgr_t::thread_proc started."; BOOST_LOG_TRIVIAL(info) << "cli_callback_mgr_t::thread_proc started.";
while(1) { while(1) {
lck.lock(); lck.lock();
@ -266,7 +267,9 @@ typedef struct _cli_callback_mgr {
m_thread = create_thread([this]{ m_thread = create_thread([this]{
this->thread_proc(); this->thread_proc();
}); });
m_condition.wait(lck, [this](){ return m_started; });
lck.unlock(); lck.unlock();
m_condition.notify_one();
BOOST_LOG_TRIVIAL(info) << "cli_callback_mgr_t::start successfully."; BOOST_LOG_TRIVIAL(info) << "cli_callback_mgr_t::start successfully.";
return true; return true;
} }
@ -523,6 +526,8 @@ int CLI::run(int argc, char **argv)
BOOST_LOG_TRIVIAL(info) << boost::format("Will use pipe %1%")%pipe_name; BOOST_LOG_TRIVIAL(info) << boost::format("Will use pipe %1%")%pipe_name;
#if defined(__linux__) || defined(__LINUX__) #if defined(__linux__) || defined(__LINUX__)
g_cli_callback_mgr.start(pipe_name); g_cli_callback_mgr.start(pipe_name);
PrintBase::SlicingStatus slicing_status{1, "Start to load files"};
cli_status_callback(slicing_status);
#endif #endif
} }
} }
@ -1391,7 +1396,7 @@ int CLI::run(int argc, char **argv)
BOOST_LOG_TRIVIAL(info) << "will start transforms, commands count " << m_transforms.size() << "\n"; BOOST_LOG_TRIVIAL(info) << "will start transforms, commands count " << m_transforms.size() << "\n";
#if defined(__linux__) || defined(__LINUX__) #if defined(__linux__) || defined(__LINUX__)
if (g_cli_callback_mgr.is_started()) { if (g_cli_callback_mgr.is_started()) {
PrintBase::SlicingStatus slicing_status{1, "Loading files finished"}; PrintBase::SlicingStatus slicing_status{2, "Loading files finished"};
cli_status_callback(slicing_status); cli_status_callback(slicing_status);
} }
#endif #endif