Răsfoiți Sursa

优化启动与停止响应速度

xx 2 ani în urmă
părinte
comite
8713783cef
3 a modificat fișierele cu 22 adăugiri și 5 ștergeri
  1. 10 1
      src/core/define.h
  2. 4 3
      src/core/log.cpp
  3. 8 1
      src/core/statemanager.cpp

+ 10 - 1
src/core/define.h

@@ -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);                  \
+    }   

+ 4 - 3
src/core/log.cpp

@@ -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)

+ 8 - 1
src/core/statemanager.cpp

@@ -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;
 }