本文整理汇总了C++中boost::weak_ptr类的典型用法代码示例。如果您正苦于以下问题:C++ weak_ptr类的具体用法?C++ weak_ptr怎么用?C++ weak_ptr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了weak_ptr类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: Insert
void SceneDict::Insert(boost::weak_ptr<zeitgeist::Leaf> leaf, const FileRef& ref)
{
if (leaf.expired())
{
return;
}
mDictionary[leaf] = ref;
}
开发者ID:MadMaxPavlo,项目名称:SimSpark-SPL,代码行数:9,代码来源:scenedict.cpp
示例14: weakDeleteCallback
static void weakDeleteCallback(const boost::weak_ptr<StockFactory>& wkFactory, Stock* stock)
{
shared_ptr<StockFactory> factory(wkFactory.lock());
if (factory)
{
factory->removeStock(stock);
}
delete stock;
}
开发者ID:szqh97,项目名称:test,代码行数:9,代码来源:Factory.cpp
示例15: hasPeakAddModeFor
bool CompositePeaksPresenter::hasPeakAddModeFor(boost::weak_ptr<const Mantid::API::IPeaksWorkspace> target){
bool hasMode = false;
if(auto temp = target.lock()) {
auto it = this->getPresenterIteratorFromWorkspace(temp);
if(it != m_subjects.end()) {
hasMode = (*it)->hasPeakAddMode();
}
}
return hasMode;
}
开发者ID:nimgould,项目名称:mantid,代码行数:10,代码来源:CompositePeaksPresenter.cpp
示例16: assert
void ribi::trim::Face::AddBelongsTo(boost::weak_ptr<const Cell> cell)
{
assert(cell.lock());
m_belongs_to.push_back(cell);
assert(m_belongs_to.size() <= 2);
assert(
(m_belongs_to.size() == 1)
|| (m_belongs_to.size() == 2 && m_belongs_to[0].lock() != m_belongs_to[1].lock())
);
}
开发者ID:richelbilderbeek,项目名称:RibiClasses,代码行数:10,代码来源:trianglemeshface.cpp
示例17: onHighWaterMarkWeak
void Tunnel::onHighWaterMarkWeak(const boost::weak_ptr<Tunnel>& wkTunnel,
const ConnectionPtr& conn,
size_t bytesToSent)
{
LOG_ERROR("onHighWaterMark " << conn->name() << " bytes " << bytesToSent);
boost::shared_ptr<Tunnel> tunnel = wkTunnel.lock();
if (tunnel)
{
tunnel->onHighWaterMark(conn, bytesToSent);
}
}
开发者ID:aoyoo,项目名称:sevent,代码行数:11,代码来源:Tunnel.cpp
示例18: new_global_session
libusb::session::sptr libusb::session::get_global_session(void){
static boost::weak_ptr<session> global_session;
//not expired -> get existing session
if (not global_session.expired()) return global_session.lock();
//create a new global session
sptr new_global_session(new libusb_session_impl());
global_session = new_global_session;
//set logging if envvar is set
const char *level_string = getenv("LIBUSB_DEBUG_LEVEL");
if (level_string != NULL)
{
const int level = int(level_string[0] - '0'); //easy conversion to integer
if (level >= 0 and level <= 3) libusb_set_debug(new_global_session->get_context(), level);
}
return new_global_session;
}
开发者ID:13572293130,项目名称:uhd,代码行数:20,代码来源:libusb1_base.cpp
示例19: stubOnTimer
static void
stubOnTimer(
boost::weak_ptr<void> weakCond, boost::function<void ()> dg)
{
boost::shared_ptr<void> temp = weakCond.lock();
if (temp) {
dg();
} else {
MORDOR_LOG_DEBUG(g_log) << " Conditionally skip in stubOnTimer!";
}
}
开发者ID:fathomdb,项目名称:mordor,代码行数:11,代码来源:timer.cpp
示例20: 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
注:本文中的boost::weak_ptr类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论