Init: don't pay for unused module

Networking can be very slow
This commit is contained in:
李通洲
2022-09-29 17:14:50 +08:00
parent 9cf95620a9
commit 8a52836afc
3 changed files with 17 additions and 4 deletions
-4
View File
@@ -363,10 +363,6 @@ static void exitSignalHandler(int signal)
void ffStart(FFinstance* instance)
{
ffPrepareCPUUsage();
ffPreparePublicIp(instance);
ffPrepareWeather(instance);
if(instance->config.multithreading)
startDetectionThreads(instance);
+13
View File
@@ -1485,6 +1485,19 @@ int main(int argc, const char** argv)
if(data.structure.length == 0)
ffStrbufAppendS(&data.structure, FASTFETCH_DATATEXT_STRUCTURE);
#define FF_CONTAINS_MODULE_NAME(moduleName)\
ffStrbufContainIgnCaseS(&data.structure, ":" #moduleName ":") ||\
ffStrbufStartsWithIgnCaseS(&data.structure, #moduleName ":") ||\
ffStrbufEndsWithIgnCaseS(&data.structure, ":" #moduleName)
if(FF_CONTAINS_MODULE_NAME(CPUUsage))
ffPrepareCPUUsage();
if(FF_CONTAINS_MODULE_NAME(PublicIp))
ffPreparePublicIp(&instance);
if(FF_CONTAINS_MODULE_NAME(Weather))
ffPrepareWeather(&instance);
#undef FF_CONTAINS_MODULE_NAME
ffStart(&instance);
//Parse the structure and call the modules
+4
View File
@@ -10,6 +10,10 @@ int main(int argc, char** argv)
//Modify instance.config here
// ffPrepareCPUUsage();
// ffPreparePublicIp(&instance);
// ffPrepareWeather(&instance);
//Does things like starting detection threads, disabling line wrap, etc
ffStart(&instance);