本文整理汇总了C++中intrusive_ptr::ptr方法的典型用法代码示例。如果您正苦于以下问题:C++ intrusive_ptr::ptr方法的具体用法?C++ intrusive_ptr::ptr怎么用?C++ intrusive_ptr::ptr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类intrusive_ptr
的用法示例。
在下文中一共展示了intrusive_ptr::ptr方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handle
virtual int handle(int pollf) {
log.trace() << "Sending request to server";
const std::string *errordesc = 0;
try {
off += sock()->write(request_buf->ptr() + off,
request_buf->size() - off);
if (request_buf->size() == off) {
log.trace() << "Request is sent completely";
intrusive_ptr<pipe> writer(new pipe(client_sock, queue()));
intrusive_ptr<pipe> reader(new pipe(sock(), queue(), new buffer(), writer));
queue().push(reader, POLLIN);
return 0;
}
return POLLOUT;
} catch (errno_exception &e) {
switch (e.errnum()) {
case ENOMEM:
case ENOBUFS:
errordesc = &error_pages::service_unavailable;
break;
case ECONNREFUSED:
case ENOTCONN:
case ENOTSOCK:
errordesc = &error_pages::bad_gateway;
break;
default:
errordesc = &error_pages::internal_error;
break;
}
} catch (std::bad_alloc &e) {
errordesc = &error_pages::service_unavailable;
} catch (std::length_error &e) {
errordesc = &error_pages::bad_request;
} catch (...) {
errordesc = &error_pages::internal_error;
}
if (errordesc) {
queue().push(
new static_response_handler(*errordesc, client_sock,
queue()), POLLOUT);
}
return 0;
}
示例2: handle_in
int handle_in() {
assert(buf);
assert(other_side);
ssize_t resize = sock()->read(buf->ptr(), buf->capacity());
buf->size(resize);
if (resize == 0) {
return 0;
}
queue().push(other_side, POLLOUT);
other_side->other_side = intrusive_ptr<pipe>::from_existing(this);
other_side = 0;
return 0;
}