use std::shared_from_this

This commit is contained in:
Jeff Becker 2017-01-16 07:54:56 -05:00
parent c68aca4ada
commit 77918fd412
2 changed files with 9 additions and 5 deletions

View file

@ -182,7 +182,8 @@ namespace datagram
// we used this session
m_LastUse = i2p::util::GetMillisecondsSinceEpoch();
// schedule send
m_LocalDestination->GetService().post(std::bind(&DatagramSession::HandleSend, this, msg));
auto self = shared_from_this();
m_LocalDestination->GetService().post(std::bind(&DatagramSession::HandleSend, self, msg));
}
DatagramSession::Info DatagramSession::GetSessionInfo() const
@ -334,7 +335,8 @@ namespace datagram
{
boost::posix_time::milliseconds dlt(100);
m_SendQueueTimer.expires_from_now(dlt);
m_SendQueueTimer.async_wait([this](const boost::system::error_code & ec) { if(ec) return; FlushSendQueue(); });
auto self = shared_from_this();
m_SendQueueTimer.async_wait([self](const boost::system::error_code & ec) { if(ec) return; self->FlushSendQueue(); });
}
}
}