本文整理汇总了C++中observer_ptr::algorithm方法的典型用法代码示例。如果您正苦于以下问题:C++ observer_ptr::algorithm方法的具体用法?C++ observer_ptr::algorithm怎么用?C++ observer_ptr::algorithm使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类observer_ptr
的用法示例。
在下文中一共展示了observer_ptr::algorithm方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: invoke
bool rpc_manager::invoke(entry& e, udp::endpoint target_addr
, observer_ptr o)
{
INVARIANT_CHECK;
if (m_destructing) return false;
e["y"] = "q";
entry& a = e["a"];
add_our_id(a);
std::string transaction_id;
transaction_id.resize(2);
char* out = &transaction_id[0];
int tid = (random() ^ (random() << 5)) & 0xffff;
io::write_uint16(tid, out);
e["t"] = transaction_id;
// When a DHT node enters the read-only state, in each outgoing query message,
// places a 'ro' key in the top-level message dictionary and sets its value to 1.
if (m_settings.read_only) e["ro"] = 1;
node& n = o->algorithm()->get_node();
if (!n.native_address(o->target_addr()))
{
a["want"].list().push_back(entry(n.protocol_family_name()));
}
o->set_target(target_addr);
o->set_transaction_id(tid);
#ifndef TORRENT_DISABLE_LOGGING
m_log->log(dht_logger::rpc_manager, "[%p] invoking %s -> %s"
, static_cast<void*>(o->algorithm()), e["q"].string().c_str()
, print_endpoint(target_addr).c_str());
#endif
if (m_sock->send_packet(e, target_addr))
{
m_transactions.insert(std::make_pair(tid, o));
#if TORRENT_USE_ASSERTS
o->m_was_sent = true;
#endif
return true;
}
return false;
}
示例2: invoke
bool rpc_manager::invoke(entry& e, udp::endpoint target_addr
, observer_ptr o)
{
INVARIANT_CHECK;
if (m_destructing) return false;
e["y"] = "q";
entry& a = e["a"];
add_our_id(a);
std::string transaction_id;
transaction_id.resize(2);
char* out = &transaction_id[0];
int tid = (random() ^ (random() << 5)) & 0xffff;
io::write_uint16(tid, out);
e["t"] = transaction_id;
o->set_target(target_addr);
o->set_transaction_id(tid);
#ifndef TORRENT_DISABLE_LOGGING
m_log->log(dht_logger::rpc_manager, "[%p] invoking %s -> %s"
, static_cast<void*>(o->algorithm()), e["q"].string().c_str()
, print_endpoint(target_addr).c_str());
#endif
if (m_sock->send_packet(e, target_addr, 1))
{
m_transactions.insert(std::make_pair(tid,o));
#if TORRENT_USE_ASSERTS
o->m_was_sent = true;
#endif
return true;
}
return false;
}