Archived
This forum has been archived. Please start a new discussion on GitHub.
Questions about __setNoDelete()
in Help Center
hi,
Although the Manu p215 has given some explainations about the __setNoDelete, I am not very clear yet . Could you please say a little more on it?
Moreover,in the source file Blobject.cpp , I can not understand why using two __setNoDelete(false) methods in the constructor of the blobject while without __setNoDelete(true).
Thank you very much.
OrNot
Although the Manu p215 has given some explainations about the __setNoDelete, I am not very clear yet . Could you please say a little more on it?
Moreover,in the source file Blobject.cpp , I can not understand why using two __setNoDelete(false) methods in the constructor of the blobject while without __setNoDelete(true).
Thank you very much.
OrNot
0
Comments
-
OrNot wrote:Although the Manu p215 has given some explainations about the __setNoDelete, I am not very clear yet . Could you please say a little more on it?
There really isn't much to say. __setNoDelete simply prevents deletion of an object if the last smart pointer to it goes out of scope. You can check the implemention by looking at IceUtil/Shared.h.Moreover,in the source file Blobject.cpp , I can not understand why using two __setNoDelete(false) methods in the constructor of the blobject while without __setNoDelete(true).
Sorry, but you'll have to be more precise. There is no file Blobject.cpp, only Object.cpp (in which Blobject is implemented). But Blobject has neither a constructor, nor are there any calls to __setNoDelete in Object.cpp. So I'm not sure which part of the code you mean.
Cheers,
Michi.0 -
hi, Michi,
Here are the codes excerpted from Blobject.cpp, an implementation file of Glacier2.
Glacier2::Blobject::Blobject(const CommunicatorPtr& communicator, bool reverse) :
_communicator(communicator),
_properties(_communicator->getProperties()),
_logger(_communicator->getLogger()),
_reverse(reverse),
_forwardContext(_reverse ?
_properties->getPropertyAsInt(serverForwardContext) > 0 :
_properties->getPropertyAsInt(clientForwardContext) > 0),
_buffered(_reverse ?
_properties->getPropertyAsIntWithDefault(serverBuffered, 1) > 0 :
_properties->getPropertyAsIntWithDefault(clientBuffered, 1) > 0),
_alwaysBatch(_reverse ?
_properties->getPropertyAsInt(serverAlwaysBatch) > 0 :
_properties->getPropertyAsInt(clientAlwaysBatch) > 0),
_requestTraceLevel(_reverse ?
_properties->getPropertyAsInt(serverTraceRequest) :
_properties->getPropertyAsInt(clientTraceRequest)),
_overrideTraceLevel(reverse ?
_properties->getPropertyAsInt(serverTraceOverride) :
_properties->getPropertyAsInt(clientTraceOverride))
{
if(_buffered)
{
try
{
IceUtil::Time sleepTime = _reverse ?
IceUtil::Time::milliSeconds(_properties->getPropertyAsInt(serverSleepTime)) :
IceUtil::Time::milliSeconds(_properties->getPropertyAsInt(clientSleepTime));
_requestQueue = new RequestQueue(sleepTime);
Int threadStackSize = _properties->getPropertyAsInt("Ice.ThreadPerConnection.StackSize");
_requestQueue->start(static_cast<size_t>(threadStackSize));
//
// See the comment in Glacier2::RequestQueue::destroy()
// for why we detach the thread.
//
_requestQueue->getThreadControl().detach();
}
catch(const IceUtil::Exception& ex)
{
{
Error out(_logger);
out << "cannot create thread for request queue:\n" << ex;
}
if(_requestQueue)
{
_requestQueue->destroy();
_requestQueue = 0;
}
__setNoDelete(false);
throw;
}
__setNoDelete(false);
}
}
There may lack of a __setNoDelete(true) before the try block. But I am not very sure.
Best regards
OrNot0 -
That looks like some old code that should have been removed. At any rate, they won't do any harm.
Regards, Matthew0 -
hi,Matthew,
The codes come from 2.1.2. That file was last updated on 04-02-2005. Isn't it the newest version?0 -
Yes, its the newest version.
Matthew0