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


C++ connection_ptr::detach方法代码示例

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


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

示例1: remove_connection

 /**
  * This function erases a connection from the list managed by the endpoint.
  * After this function returns, endpoint all async events related to this
  * connection should be canceled and neither ASIO nor this endpoint should
  * have a pointer to this connection. Unless the end user retains a copy of
  * the shared pointer the connection will be freed and any state it 
  * contained (close code status, etc) will be lost.
  * 
  * Visibility: protected
  * State: Always valid, behavior differs based on state
  * Concurrency: Callable from anywhere
  * 
  * @param con A shared pointer to a connection created by this endpoint.
  */
 void remove_connection(connection_ptr con) {
     boost::lock_guard<boost::recursive_mutex> lock(m_lock);
     
     // TODO: is this safe to use?
     // Detaching signals to the connection that the endpoint is no longer aware of it
     // and it is no longer safe to assume the endpoint exists.
     con->detach();
     
     m_connections.erase(con);
     
     m_alog->at(log::alevel::DEVEL) << "Connection removed: count is now: " 
                                    << m_connections.size() << log::endl;
     
     if (m_state == STOPPING && m_connections.empty()) {
         // If we are in the process of stopping and have reached zero
         // connections stop the io_service.
         m_alog->at(log::alevel::ENDPOINT) 
             << "Endpoint has reached zero connections in STOPPING state. Stopping io_service now." 
             << log::endl;
         stop(false);
     }
 }
开发者ID:BattleProgrammer,项目名称:stellard,代码行数:36,代码来源:endpoint.hpp


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