Commit 057660af authored by Pavel Vainerman's avatar Pavel Vainerman

Сделал UniSetTimer в UniSetObject shared_ptr-ов

(в рамках перевода "всего и вся" на использование умных указателей из c++11).
parent 207347d9
...@@ -201,7 +201,7 @@ class UniSetObject: ...@@ -201,7 +201,7 @@ class UniSetObject:
friend class UniSetManager; friend class UniSetManager;
friend class UniSetActivator; friend class UniSetActivator;
friend class ThreadCreator<UniSetObject>;
inline pid_t getMsgPID() inline pid_t getMsgPID()
{ {
return msgpid; return msgpid;
...@@ -227,10 +227,11 @@ class UniSetObject: ...@@ -227,10 +227,11 @@ class UniSetObject:
std::atomic_bool active; std::atomic_bool active;
bool threadcreate; bool threadcreate;
UniSetTimer* tmr; std::shared_ptr<UniSetTimer> tmr;
UniSetTypes::ObjectId myid; UniSetTypes::ObjectId myid;
CORBA::Object_var oref; CORBA::Object_var oref;
ThreadCreator<UniSetObject>* thr;
std::shared_ptr< ThreadCreator<UniSetObject> > thr;
/*! очередь сообщений для объекта */ /*! очередь сообщений для объекта */
MessagesQueue queueMsg; MessagesQueue queueMsg;
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
using namespace std; using namespace std;
using namespace UniSetTypes; using namespace UniSetTypes;
#define CREATE_TIMER new ThrPassiveTimer(); #define CREATE_TIMER make_shared<ThrPassiveTimer>();
// new PassiveSysTimer(); // new PassiveSysTimer();
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
...@@ -51,10 +51,8 @@ msgpid(0), ...@@ -51,10 +51,8 @@ msgpid(0),
reg(false), reg(false),
active(0), active(0),
threadcreate(false), threadcreate(false),
tmr(NULL),
myid(UniSetTypes::DefaultObjectId), myid(UniSetTypes::DefaultObjectId),
oref(0), oref(0),
thr(NULL),
SizeOfMessageQueue(1000), SizeOfMessageQueue(1000),
MaxCountRemoveOfMessage(10), MaxCountRemoveOfMessage(10),
stMaxQueueMessages(0), stMaxQueueMessages(0),
...@@ -73,10 +71,8 @@ msgpid(0), ...@@ -73,10 +71,8 @@ msgpid(0),
reg(false), reg(false),
active(0), active(0),
threadcreate(true), threadcreate(true),
tmr(NULL),
myid(id), myid(id),
oref(0), oref(0),
thr(NULL),
SizeOfMessageQueue(1000), SizeOfMessageQueue(1000),
MaxCountRemoveOfMessage(10), MaxCountRemoveOfMessage(10),
stMaxQueueMessages(0), stMaxQueueMessages(0),
...@@ -108,10 +104,8 @@ msgpid(0), ...@@ -108,10 +104,8 @@ msgpid(0),
reg(false), reg(false),
active(0), active(0),
threadcreate(true), threadcreate(true),
tmr(NULL),
myid(UniSetTypes::DefaultObjectId), myid(UniSetTypes::DefaultObjectId),
oref(0), oref(0),
thr(NULL),
SizeOfMessageQueue(1000), SizeOfMessageQueue(1000),
MaxCountRemoveOfMessage(10), MaxCountRemoveOfMessage(10),
stMaxQueueMessages(0), stMaxQueueMessages(0),
...@@ -155,11 +149,7 @@ UniSetObject::~UniSetObject() ...@@ -155,11 +149,7 @@ UniSetObject::~UniSetObject()
thr->join(); thr->join();
} }
catch(...){} catch(...){}
delete thr;
} }
delete tmr;
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
void UniSetObject::init_object() void UniSetObject::init_object()
...@@ -446,7 +436,7 @@ CORBA::Boolean UniSetObject::exist() ...@@ -446,7 +436,7 @@ CORBA::Boolean UniSetObject::exist()
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
void UniSetObject::termWaiting() void UniSetObject::termWaiting()
{ {
if( tmr!=NULL ) if( tmr )
tmr->terminate(); tmr->terminate();
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
...@@ -747,7 +737,7 @@ bool UniSetObject::activate() ...@@ -747,7 +737,7 @@ bool UniSetObject::activate()
if( myid!=UniSetTypes::DefaultObjectId && threadcreate ) if( myid!=UniSetTypes::DefaultObjectId && threadcreate )
{ {
thr = new ThreadCreator<UniSetObject>(this, &UniSetObject::work); thr = make_shared< ThreadCreator<UniSetObject> >(this, &UniSetObject::work);
thr->start(); thr->start();
} }
else else
......
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