still working on RAII

This commit is contained in:
mrkraimer
2016-05-19 12:01:21 -04:00
parent adc008dee6
commit a0cc581d3f
4 changed files with 31 additions and 40 deletions

View File

@@ -149,25 +149,12 @@ PvaClientChannel::~PvaClientChannel()
<< " this " << this << " channel " << channel
<< endl;
}
destroy();
}
void PvaClientChannel::destroy()
{
{
{
Lock xx(mutex);
if(isDestroyed) return;
isDestroyed = true;
}
if(PvaClient::getDebug()) {
cout << "PvaClientChannel::destroy() "
<< " channelName " << channelName
<< " this " << this << " channel " << channel
<< endl;
}
if(PvaClient::getDebug()) showCache();
if(channel) channel->destroy();
if(channel) channel.reset();
pvaClientGetCache.reset();
pvaClientPutCache.reset();
}
@@ -233,8 +220,7 @@ void PvaClientChannel::channelStateChange(
string PvaClientChannel::getRequesterName()
{
PvaClientPtr yyy = pvaClient.lock();
if(!yyy) throw std::runtime_error(
"PvaClientChannel::getRequesterName() PvaClient isDestroyed");
if(!yyy) return string("PvaClientChannel::getRequesterName() PvaClient isDestroyed");
return yyy->getRequesterName();
}
@@ -243,8 +229,7 @@ void PvaClientChannel::message(
MessageType messageType)
{
PvaClientPtr yyy = pvaClient.lock();
if(!yyy) throw std::runtime_error(
"PvaClientChannel::message() pvaClient isDestroyed");
if(!yyy) return;
yyy->message(channelName + " " + message, messageType);
}