本文整理汇总了C++中Flow::token方法的典型用法代码示例。如果您正苦于以下问题:C++ Flow::token方法的具体用法?C++ Flow::token怎么用?C++ Flow::token使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Flow
的用法示例。
在下文中一共展示了Flow::token方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: find_create_flow
/// Find or create a flow corresponding to the specified transport and remote
/// IP address and port. This is a single method to ensure it is atomic.
Flow* FlowTable::find_create_flow(pjsip_transport* transport, const pj_sockaddr* raddr)
{
Flow* flow = NULL;
FlowKey key(transport->key.type, raddr);
char buf[100];
LOG_DEBUG("Find or create flow for transport %s (%d), remote address %s",
transport->obj_name, transport->key.type,
pj_sockaddr_print(raddr, buf, sizeof(buf), 3));
pthread_mutex_lock(&_flow_map_lock);
std::map<FlowKey, Flow*>::iterator i = _tp2flow_map.find(key);
if (i == _tp2flow_map.end())
{
// No matching flow, so create a new one.
flow = new Flow(this, transport, raddr);
// Add the new flow to the maps.
_tp2flow_map.insert(std::make_pair(key, flow));
_tk2flow_map.insert(std::make_pair(flow->token(), flow));
LOG_DEBUG("Added flow record %p", flow);
report_flow_count();
}
else
{
// Found a matching flow, so return this one.
flow = i->second;
LOG_DEBUG("Found flow record %p", flow);
}
// Add a reference to the flow.
flow->inc_ref();
pthread_mutex_unlock(&_flow_map_lock);
return flow;
}