Commit e12b4c58 authored by Pavel Vainerman's avatar Pavel Vainerman

(UniSetActivator): Переделал механизм завершения процессов. Чтбоы не было "SIGSEGV"

parent 055a718a
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#define OmniThreadCreator_h_ #define OmniThreadCreator_h_
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
#include <omnithread.h> #include <omnithread.h>
#include <memory>
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
/*! \class OmniThreadCreator /*! \class OmniThreadCreator
* \par * \par
...@@ -94,16 +95,20 @@ class OmniThreadCreator: ...@@ -94,16 +95,20 @@ class OmniThreadCreator:
public: public:
/*! прототип функции вызова */ /*! прототип функции вызова */
typedef void(ThreadMaster::* Action)(void*); typedef void(ThreadMaster::* Action)();
OmniThreadCreator( ThreadMaster* m, Action a, bool undetached=false ); OmniThreadCreator( const std::shared_ptr<ThreadMaster>& m, Action a, bool undetached=false );
~OmniThreadCreator(){}; ~OmniThreadCreator(){}
inline bool isRunning(){ return state()==omni_thread::STATE_RUNNING; }
inline void stop(){ exit(0); }
inline pid_t getTID(){ return id(); }
protected: protected:
void* run_undetached(void *x) void* run_undetached(void *x)
{ {
if(m) if(m)
(m->*act)(x); (m.get()->*act)();
return (void*)0; return (void*)0;
} }
...@@ -111,20 +116,20 @@ class OmniThreadCreator: ...@@ -111,20 +116,20 @@ class OmniThreadCreator:
virtual void run(void* arg) virtual void run(void* arg)
{ {
if(m) if(m)
(m->*act)(arg); (m.get()->*act)();
} }
private: private:
OmniThreadCreator(); OmniThreadCreator();
ThreadMaster* m; std::shared_ptr<ThreadMaster> m;
Action act; Action act;
}; };
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
template <class ThreadMaster> template <class ThreadMaster>
OmniThreadCreator<ThreadMaster>::OmniThreadCreator( ThreadMaster* m, Action a, bool undetach ): OmniThreadCreator<ThreadMaster>::OmniThreadCreator( const std::shared_ptr<ThreadMaster>& _m, Action a, bool undetach ):
omni_thread(), omni_thread(),
m(m), m(_m),
act(a) act(a)
{ {
if(undetach) if(undetach)
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#include "UniSetTypes.h" #include "UniSetTypes.h"
#include "UniSetObject.h" #include "UniSetObject.h"
#include "UniSetManager.h" #include "UniSetManager.h"
#include "ThreadCreator.h" #include "OmniThreadCreator.h"
//#include "OmniThreadCreator.h" //#include "OmniThreadCreator.h"
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
...@@ -122,10 +122,11 @@ class UniSetActivator: ...@@ -122,10 +122,11 @@ class UniSetActivator:
void term( int signo ); void term( int signo );
void init(); void init();
std::shared_ptr< ThreadCreator<UniSetActivator> > orbthr; std::shared_ptr< OmniThreadCreator<UniSetActivator> > orbthr;
CORBA::ORB_var orb; CORBA::ORB_var orb;
TerminateEvent_Signal s_term; TerminateEvent_Signal s_term;
ost::AtomicCounter orbthrIsFinished;
bool omDestroy; bool omDestroy;
bool sig; bool sig;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment