本文整理汇总了C++中ice::ConnectionPtr::setHeartbeatCallback方法的典型用法代码示例。如果您正苦于以下问题:C++ ConnectionPtr::setHeartbeatCallback方法的具体用法?C++ ConnectionPtr::setHeartbeatCallback怎么用?C++ ConnectionPtr::setHeartbeatCallback使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ice::ConnectionPtr
的用法示例。
在下文中一共展示了ConnectionPtr::setHeartbeatCallback方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sync
void
ReapThread::add(const ReapablePtr& reapable, int timeout, const Ice::ConnectionPtr& connection)
{
Lock sync(*this);
if(_terminated)
{
return;
}
//
// NOTE: registering a reapable with a null timeout is allowed. The reapable is reaped
// only when the reaper thread is shutdown.
//
//
// 10 seconds is the minimum permissable timeout.
//
if(timeout > 0 && timeout < 10)
{
timeout = 10;
}
ReapableItem item;
item.item = reapable;
item.connection = connection;
item.timeout = timeout == 0 ? IceUtil::Time() : IceUtil::Time::seconds(timeout);
_sessions.push_back(item);
if(connection)
{
map<Ice::ConnectionPtr, set<ReapablePtr> >::iterator p = _connections.find(connection);
if(p == _connections.end())
{
p = _connections.insert(make_pair(connection, set<ReapablePtr>())).first;
connection->setCloseCallback(_closeCallback);
connection->setHeartbeatCallback(_heartbeatCallback);
}
p->second.insert(reapable);
}
if(timeout > 0)
{
//
// If there is a new minimum wake interval then wake the reaping
// thread.
//
if(calcWakeInterval())
{
notify();
}
//
// Since we just added a new session with a non null timeout there
// must be a non-zero wakeInterval.
//
assert(_wakeInterval != IceUtil::Time());
}
}