From 9a44caeb992e365d747fa9f6900310f72785836a Mon Sep 17 00:00:00 2001 From: Gluzskiy Alexandr Date: Tue, 3 Aug 2010 13:22:34 +0300 Subject: starting plugins in threads --- core/main.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'core/main.cpp') diff --git a/core/main.cpp b/core/main.cpp index ae1dbf0..aa6a7fc 100644 --- a/core/main.cpp +++ b/core/main.cpp @@ -16,6 +16,7 @@ list services; int LoadModules(); INT_PTR CallService(const char *name, WPARAM w, LPARAM l); HANDLE CreateServiceFunction(const char *name, SERVICE pService); +DWORD WINAPI OnModulesLoadedThread( LPVOID lpParam ); int ServiceExists(const char *name); SERVICE GetPluginInfoList(WPARAM, LPARAM); SERVICE Test(WPARAM, LPARAM); @@ -35,7 +36,10 @@ int main(int argc, char *argv[]) for(list::iterator p = plugins.begin(); p != plugins.end(); p++) { if((*p)->getFuncs().loaded) - (*p)->getFuncs().loaded(); + { + CreateThread(NULL, 0, OnModulesLoadedThread, (LPVOID)(*p)->getFuncs().loaded, 0, 0); +// (*p)->getFuncs().loaded(); + } } CallService("GetPluginInfoList", 0, 0); for(;;) @@ -146,7 +150,8 @@ INT_PTR CallService(const char *name, WPARAM w, LPARAM l) } HANDLE CreateServiceFunction(const char *name, SERVICE pService) { - services.push_back(new service(name, pService)); + if(!ServiceExists(name)) + services.push_back(new service(name, pService)); } int ServiceExists(const char *name) { @@ -168,3 +173,11 @@ SERVICE Test(WPARAM, LPARAM) MessageBoxA(0, "Test service working", "INFO", MB_OK); return 0; } + +DWORD WINAPI OnModulesLoadedThread( LPVOID lpParam ) +{ + OnModulesLoaded &l = (OnModulesLoaded&)lpParam; + l(); + return 0; +} + -- cgit v1.2.3