summaryrefslogtreecommitdiff
path: root/core/main.cpp
diff options
context:
space:
mode:
authorGluzskiy Alexandr <sss123next@list.ru>2010-11-22 04:34:42 +0200
committerGluzskiy Alexandr <sss123next@list.ru>2010-11-22 04:34:42 +0200
commitba3095b937bd051ca1438a837245d21db300a0d6 (patch)
tree886b316e24f52e60314d6fb1d4b63ea741f0506e /core/main.cpp
parentbaba7489c48a759bdf6479e718a28f1339aaac54 (diff)
core services
Diffstat (limited to 'core/main.cpp')
-rw-r--r--core/main.cpp49
1 files changed, 30 insertions, 19 deletions
diff --git a/core/main.cpp b/core/main.cpp
index 64c14d5..4a71738 100644
--- a/core/main.cpp
+++ b/core/main.cpp
@@ -22,10 +22,32 @@ boost::mutex plugin_list_mutex;
std::list<service*> services;
boost::mutex service_list_mutex;
ACE_Log_Msg logger;
+bool halt_requested = false;
PLUGINLINK pluglink = {&CreateServiceFunction, &CallService, &ServiceExists};
+int on_exit()
+{
+ plugin_list_mutex.lock();
+ service_list_mutex.lock();
+ if(!services.empty())
+ {
+ std::list<service*>::iterator end = services.end();
+ for(std::list<service*>::iterator i = services.begin(); i != end; ++i)
+ delete *i;
+ services.clear();
+ }
+ if(!plugins.empty())
+ {
+ std::list<plugin*>::iterator end = plugins.end();
+ for(std::list<plugin*>::iterator i = plugins.begin(); i != end; ++i)
+ delete *i;
+ plugins.clear();
+ }
+ return 0;
+}
+
#ifdef _WIN32
HINSTANCE hInst;
int __stdcall WinMain( __in HINSTANCE hInstance, __in_opt HINSTANCE hPrevInstance, __in_opt LPSTR lpCmdLine, __in int nShowCmd )
@@ -47,27 +69,16 @@ int ACE_MAIN(int argc, char *argv[])
while(true)
{
logger.log(LM_DEBUG, "Main threas sleeping...\n");
- boost::this_thread::sleep(boost::posix_time::seconds(10)); //warning from compiller on this string can be safely ignored
+ boost::this_thread::sleep(boost::posix_time::seconds(5));
+ if(halt_requested)
+ break;
}
return 0;
}
-
-int on_exit()
+void terminate()
{
- if(!services.empty())
- {
- std::list<service*>::iterator end = services.end();
- for(std::list<service*>::iterator i = services.begin(); i != end; ++i)
- delete *i;
- services.clear();
- }
- if(!plugins.empty())
- {
- std::list<plugin*>::iterator end = plugins.end();
- for(std::list<plugin*>::iterator i = plugins.begin(); i != end; ++i)
- delete *i;
- plugins.clear();
- }
- return 0;
-} \ No newline at end of file
+ if(on_exit())
+ logger.log(LM_DEBUG, "Something bad happened on exit");
+}
+