本文整理汇总了C++中WeakReference::Get方法的典型用法代码示例。如果您正苦于以下问题:C++ WeakReference::Get方法的具体用法?C++ WeakReference::Get怎么用?C++ WeakReference::Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WeakReference
的用法示例。
在下文中一共展示了WeakReference::Get方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
static int
dump_socket(int argc, char** argv)
{
if (argc < 2) {
kprintf("usage: %s [address]\n", argv[0]);
return 0;
}
net_socket_private* socket = (net_socket_private*)parse_expression(argv[1]);
kprintf("SOCKET %p\n", socket);
kprintf(" family.type.protocol: %d.%d.%d\n",
socket->family, socket->type, socket->protocol);
WeakReference<net_socket_private> parent = socket->parent;
kprintf(" parent: %p (%p)\n", parent.Get(), socket->parent);
kprintf(" first protocol: %p\n", socket->first_protocol);
kprintf(" first module_info: %p\n", socket->first_info);
kprintf(" options: %x\n", socket->options);
kprintf(" linger: %d\n", socket->linger);
kprintf(" bound to device: %d\n", socket->bound_to_device);
kprintf(" owner: %ld\n", socket->owner);
kprintf(" max backlog: %ld\n", socket->max_backlog);
kprintf(" is connected: %d\n", socket->is_connected);
kprintf(" child_count: %lu\n", socket->child_count);
if (socket->child_count == 0)
return 0;
kprintf(" pending children:\n");
SocketList::Iterator iterator = socket->pending_children.GetIterator();
while (net_socket_private* child = iterator.Next()) {
print_socket_line(child, " ");
}
kprintf(" connected children:\n");
iterator = socket->connected_children.GetIterator();
while (net_socket_private* child = iterator.Next()) {
print_socket_line(child, " ");
}
return 0;
}
示例2: _
/*! The socket has been aborted. Steals the parent's reference, and releases
it.
*/
status_t
socket_aborted(net_socket* _socket)
{
net_socket_private* socket = (net_socket_private*)_socket;
WeakReference<net_socket_private> parent = socket->parent;
if (parent.Get() == NULL)
return B_BAD_VALUE;
MutexLocker _(parent->lock);
if (socket->is_connected)
parent->connected_children.Remove(socket);
else
parent->pending_children.Remove(socket);
parent->child_count--;
socket->RemoveFromParent();
return B_OK;
}