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


C++ boost::weak_ptr类代码示例

本文整理汇总了C++中boost::weak_ptr的典型用法代码示例。如果您正苦于以下问题:C++ weak_ptr类的具体用法?C++ weak_ptr怎么用?C++ weak_ptr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: handleWriteTimeout

void Connection::handleWriteTimeout(boost::weak_ptr<Connection> weak, const boost::system::error_code& error)
{
	if(error == boost::asio::error::operation_aborted || weak.expired())
		return;

	if(shared_ptr<Connection> connection = weak.lock())
	{
		#ifdef __DEBUG_NET_DETAIL__
		std::clog << "Connection::handleWriteTimeout" << std::endl;
		#endif
		connection->onWriteTimeout();
	}
}
开发者ID:milbradt,项目名称:TFS,代码行数:13,代码来源:connection.cpp

示例2: handleWriteTimeout

void Connection::handleWriteTimeout(boost::weak_ptr<Connection> weak_conn, const boost::system::error_code& error)
{
	if (error == boost::asio::error::operation_aborted) {
		return;
	}

	if (weak_conn.expired()) {
		return;
	}

	if (Connection_ptr connection = weak_conn.lock()) {
		connection->onWriteTimeout();
	}
}
开发者ID:nclx,项目名称:forgottenserver,代码行数:14,代码来源:connection.cpp

示例3: openAcceptor

void ServicePort::openAcceptor(boost::weak_ptr<ServicePort> weak_service, IPAddress ip, uint16_t port)
{
  if(weak_service.expired()){
    return;
  }

  if(ServicePort_ptr service = weak_service.lock()){
    #ifdef __DEBUG_NET_DETAIL__
    std::cout << "ServicePort::openAcceptor" << std::endl;
    #endif
    IPAddressList ips;
    ips.push_back(ip);
    service->open(ips, port);
  }
}
开发者ID:OMARTINEZ210,项目名称:server,代码行数:15,代码来源:server.cpp

示例4: handleReadTimeout

void Connection::handleReadTimeout(boost::weak_ptr<Connection> weak_conn, const boost::system::error_code& error)
{
	if(error != boost::asio::error::operation_aborted){
		if(weak_conn.expired()){
			return;
		}

		if(shared_ptr<Connection> connection = weak_conn.lock()){
			#ifdef __DEBUG_NET_DETAIL__
			std::cout << "Connection::handleReadTimeout" << std::endl;
			#endif

			connection->onReadTimeout();
		}
	}
}
开发者ID:angeliker,项目名称:OTHire,代码行数:16,代码来源:connection.cpp

示例5: onServiceInfoResultIfExists

 inline void onServiceInfoResultIfExists(Session_Service* s, qi::Future<qi::ServiceInfo> f,
   long requestId, std::string protocol, boost::weak_ptr<Session_Service> self)
 {
   boost::shared_ptr<Session_Service> sself = self.lock();
   if (sself)
     sself->onServiceInfoResult(f, requestId, protocol);
 }
开发者ID:cgestes,项目名称:libqi,代码行数:7,代码来源:sessionservice.cpp

示例6: add

	void add(boost::weak_ptr<SpotLightCalculator> light)
	{
		for(unsigned int i = 0; i < spots.size(); ++i)
			assert(spots[i].lock() != light.lock());

		spots.push_back(light);
	}
开发者ID:DeejStar,项目名称:Jack-Claw,代码行数:7,代码来源:LightAmountManager.cpp

示例7: TimerEntry

void PeerSet::TimerEntry (boost::weak_ptr<PeerSet> wptr, const boost::system::error_code& result)
{
    if (result == boost::asio::error::operation_aborted)
        return;

    boost::shared_ptr<PeerSet> ptr = wptr.lock ();

    if (ptr)
    {
        if (ptr->mTxnData)
        {
            getApp().getJobQueue ().addJob (jtTXN_DATA, "timerEntryTxn",
                BIND_TYPE (&PeerSet::TimerJobEntry, P_1, ptr));
        }
        else
        {
            int jc = getApp().getJobQueue ().getJobCountTotal (jtLEDGER_DATA);

            if (jc > 4)
            {
                WriteLog (lsDEBUG, InboundLedger) << "Deferring PeerSet timer due to load";
                ptr->setTimer ();
            }
            else
                getApp().getJobQueue ().addJob (jtLEDGER_DATA, "timerEntryLgr",
                    BIND_TYPE (&PeerSet::TimerJobEntry, P_1, ptr));
	}
    }
}
开发者ID:Elviso40,项目名称:rippled,代码行数:29,代码来源:PeerSet.cpp

示例8: operator

		bool operator()(boost::weak_ptr<T> arg) const {
			boost::shared_ptr<T> sp=arg.lock();
			if (!sp) {
				return false;
			}
			return func_(*sp,t_);
		}
开发者ID:zhouxicai,项目名称:ToolCode,代码行数:7,代码来源:shared_ptr_weak_ptr.cpp

示例9:

	http_seed_connection::http_seed_connection(
		session_impl& ses
		, boost::weak_ptr<torrent> t
		, boost::shared_ptr<socket_type> s
		, tcp::endpoint const& remote
		, std::string const& url
		, policy::peer* peerinfo
		, std::string const& auth
		, web_seed_entry::headers_t const& extra_headers)
		: web_connection_base(ses, t, s, remote, url, peerinfo, auth, extra_headers)
		, m_url(url)
		, m_response_left(0)
		, m_chunk_pos(0)
		, m_partial_chunk_header(0)
	{
		INVARIANT_CHECK;

		if (!ses.settings().report_web_seed_downloads)
			ignore_stats(true);

		shared_ptr<torrent> tor = t.lock();
		TORRENT_ASSERT(tor);
		int blocks_per_piece = tor->torrent_file().piece_length() / tor->block_size();

		// multiply with the blocks per piece since that many requests are
		// merged into one http request
		m_max_out_request_queue = ses.settings().urlseed_pipeline_size
			* blocks_per_piece;

		prefer_whole_pieces(1);

#ifdef TORRENT_VERBOSE_LOGGING
		peer_log("*** http_seed_connection");
#endif
	}
开发者ID:771805315,项目名称:avplayer,代码行数:35,代码来源:http_seed_connection.cpp

示例10: save

inline void save(
    Archive & ar,
    const boost::weak_ptr< T > &t,
    const unsigned int /* file_version */
){
    const boost::shared_ptr< T > sp = t.lock();
    ar << boost::serialization::make_nvp("weak_ptr", sp);
}
开发者ID:ARK1988,项目名称:nupic.core,代码行数:8,代码来源:weak_ptr.hpp

示例11: weak_call

int weak_call(int (X::*ptmf)() const, boost::weak_ptr<X> const& wp) 
{
    auto locked = wp.lock();
    if (!locked)
        throw boost::bad_weak_ptr();

    return ((*locked).*ptmf)();
}
开发者ID:CCJY,项目名称:coliru,代码行数:8,代码来源:main.cpp

示例12: queue_request

	void tracker_manager::queue_request(
		io_service& ios
		, connection_queue& cc
		, tracker_request req
		, std::string const& auth
		, boost::weak_ptr<request_callback> c)
	{
		mutex_t::scoped_lock l(m_mutex);
		TORRENT_ASSERT(req.num_want >= 0);
		TORRENT_ASSERT(!m_abort || req.event == tracker_request::stopped);
		if (m_abort && req.event != tracker_request::stopped) return;
		if (req.event == tracker_request::stopped)
			req.num_want = 0;

		TORRENT_ASSERT(!m_abort || req.event == tracker_request::stopped);
		if (m_abort && req.event != tracker_request::stopped)
			return;

		std::string protocol = req.url.substr(0, req.url.find(':'));

		boost::intrusive_ptr<tracker_connection> con;

#ifdef TORRENT_USE_OPENSSL
		if (protocol == "http" || protocol == "https")
#else
		if (protocol == "http")
#endif
		{
			con = new http_tracker_connection(
				ios, cc, *this, req, c
				, m_ses, m_proxy, auth
#if TORRENT_USE_I2P
				, &m_ses.m_i2p_conn
#endif
				);
		}
		else if (protocol == "udp")
		{
			con = new udp_tracker_connection(
				ios, cc, *this, req , c, m_ses
				, m_proxy);
		}
		else
		{
			// we need to post the error to avoid deadlock
			if (boost::shared_ptr<request_callback> r = c.lock())
				ios.post(boost::bind(&request_callback::tracker_request_error, r, req
					, -1, error_code(errors::unsupported_url_protocol)
					, "", 0));
			return;
		}

		m_connections.push_back(con);

		boost::shared_ptr<request_callback> cb = con->requester();
		if (cb) cb->m_manager = this;
		con->start();
	}
开发者ID:milindbenjamin,项目名称:libtorrent-android,代码行数:58,代码来源:tracker_manager.cpp

示例13: blockArrived

ProcessResult GetDisco::blockArrived(JabberDataBlockRef block, const ResourceContextRef rc){
    ServiceDiscovery::ref sd=vf.lock();
    if (!sd) return CANCEL;

    if (block->getAttribute("id")==idinfo) {
        if (block->getAttribute("type")=="result") {
            sd->infoReply=block->findChildNamespace("query", "http://jabber.org/protocol/disco#info");
        } else {
            if (block->getAttribute("type")=="error") {
                sd->infoReply=block->getChildByName("error");
            }
        }
        SendMessage(sd->getHWnd(), WM_NOTIFY_BLOCKARRIVED, 0,0);
        return BLOCK_PROCESSED;
    }
    if (block->getAttribute("id")==iditems) {
        if (block->getAttribute("type")=="result") {
            sd->itemReply=block->findChildNamespace("query", "http://jabber.org/protocol/disco#items");
        } else {
            if (block->getAttribute("type")=="error") {
                sd->itemReply=block->getChildByName("error");
            }
        }
        SendMessage(sd->getHWnd(), WM_NOTIFY_BLOCKARRIVED, 0,0);
        return LAST_BLOCK_PROCESSED;
    }

    return BLOCK_REJECTED;
}
开发者ID:evgs,项目名称:bombus-ng,代码行数:29,代码来源:ServiceDiscovery.cpp

示例14: eventOk

void DiscoListView::eventOk() {
    ServiceDiscovery::ref sd=serviceDiscovery.lock();
    if (!sd) return;
    
    DiscoItem::ref c=boost::dynamic_pointer_cast<DiscoItem> (cursorPos);
    if (c) {
        sd->discoverJid(c->jid, c->node);
        sd->go();
        return;
    }

    DiscoCommand::ref dc=boost::dynamic_pointer_cast<DiscoCommand> (cursorPos);
    if (dc) {
        switch (dc->cmdId) {
        case DiscoCommand::BACK: 
            sd->back();
            return;
        case DiscoCommand::VCARD:
            sd->vcard();
            return;
        case DiscoCommand::JOINGC:
            sd->joingc();
            return;
        case DiscoCommand::EXECUTE:
            sd->execute();
            return;
        case DiscoCommand::REGISTER:
            sd->registerForm();
        }
    }
    VirtualListView::eventOk();
}
开发者ID:evgs,项目名称:bombus-ng,代码行数:32,代码来源:ServiceDiscovery.cpp

示例15: runInThread

	void runInThread()
	{
		pid_t tid =	gettid();

		boost::shared_ptr<pid_t> ptid = wkTid_.lock();
		if (ptid)
		{
			*ptid = tid;
			ptid.reset();
		}

		Rabbit::CurrentThread::t_threadName = name_.empty() ? "RabbitThread" : name_.c_str();
		try
		{
			func_();
			Rabbit::CurrentThread::t_threadName = "finished";
		}
		catch (...)
		{
			Rabbit::CurrentThread::t_threadName = "crashed";
			fprintf(stderr, "some exception caught in Thread %s\n", name_.c_str());
			perror("");
			abort();
		}
	}
开发者ID:FateTHarlaown,项目名称:RabbitServer,代码行数:25,代码来源:Thread.cpp


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