当前位置: 首页>>代码示例>>C++>>正文


C++ Flow::inc_ref方法代码示例

本文整理汇总了C++中Flow::inc_ref方法的典型用法代码示例。如果您正苦于以下问题:C++ Flow::inc_ref方法的具体用法?C++ Flow::inc_ref怎么用?C++ Flow::inc_ref使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Flow的用法示例。


在下文中一共展示了Flow::inc_ref方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: find_flow

/// Find the flow corresponding to the specified transport and remote IP
/// address and port.
Flow* FlowTable::find_flow(pjsip_transport* transport, const pj_sockaddr* raddr)
{
  Flow* flow = NULL;
  FlowKey key(transport->key.type, raddr);

  char buf[100];
  LOG_DEBUG("Find 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())
  {
    // Found a matching flow, so return this one.
    flow = i->second;

    // Increment the reference count on the flow.
    flow->inc_ref();

    LOG_DEBUG("Found flow record %p", flow);
  }

  pthread_mutex_unlock(&_flow_map_lock);

  return flow;
}
开发者ID:JimBunch,项目名称:sprout,代码行数:31,代码来源:flowtable.cpp

示例2: 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;
}
开发者ID:JimBunch,项目名称:sprout,代码行数:44,代码来源:flowtable.cpp


注:本文中的Flow::inc_ref方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。