优化启动与停止响应速度

This commit is contained in:
xx
2024-06-09 23:49:24 +08:00
parent e9e080fbb8
commit 28559861b2
3 changed files with 22 additions and 5 deletions

View File

@@ -19,4 +19,13 @@
#define GET_APP sol::state_view lua(ts);fastweb::app* app = lua["____app"]
#define GET_APP sol::state_view lua(ts);fastweb::app* app = lua["____app"]
#define ITHREAD_WAIT_MSEC(MSEC) \
for(int i=0;i<(MSEC/10);i++) \
{ \
if (::ithread::m_state == 1) \
break; \
system::sleep_msec(100); \
}

View File

@@ -35,14 +35,15 @@ void fastweb::log::print(const std::string& type,const std::string& msg,const st
}
bool fastweb::log::run()
{
if (app()->config == nullptr)
{
system::sleep_msec(1000);
ITHREAD_WAIT_MSEC(1000);
return true;
}
if (app()->config->log.enable == false)
{
system::sleep_msec(1000);
ITHREAD_WAIT_MSEC(1000);
return true;
}
std::string logcontent;
@@ -68,7 +69,7 @@ bool fastweb::log::run()
{
m_file.appead(logcontent);
}
system::sleep_msec(1000);
ITHREAD_WAIT_MSEC(1000);
return true;
}
fastweb::log::log(fastweb::app* ptr):Interface(ptr)

View File

@@ -77,7 +77,14 @@ bool fastweb::state_manager::run()
{
if (lib_detecter->changed())
m_flag++;
system::sleep_msec(3000);
for (size_t i = 0; i < 30; i++)
{
if (::ithread::m_state == 1)
break;
system::sleep_msec(100);
}
return true;
}