本文整理汇总了C++中IOBufQueue::move方法的典型用法代码示例。如果您正苦于以下问题:C++ IOBufQueue::move方法的具体用法?C++ IOBufQueue::move怎么用?C++ IOBufQueue::move使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IOBufQueue
的用法示例。
在下文中一共展示了IOBufQueue::move方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: x
void helper<ProtocolReader, ProtocolWriter>::process_exn(
const char* func,
const string& msg,
unique_ptr<ResponseChannel::Request> req,
Cpp2RequestContext* ctx,
EventBase* eb,
int32_t protoSeqId) {
ProtocolWriter oprot;
if (req) {
LOG(ERROR) << msg << " in function " << func;
TApplicationException x(msg);
IOBufQueue queue = helper_w<ProtocolWriter>::write_exn(
func, &oprot, protoSeqId, nullptr, x);
queue.append(THeader::transform(
queue.move(),
ctx->getHeader()->getWriteTransforms(),
ctx->getHeader()->getMinCompressBytes()));
auto queue_mw = makeMoveWrapper(move(queue));
auto req_mw = makeMoveWrapper(move(req));
eb->runInEventBaseThread([=]() mutable {
(*req_mw)->sendReply(queue_mw->move());
});
} else {
LOG(ERROR) << msg << " in oneway function " << func;
}
}
示例2: decode
bool decode(Context* ctx,
IOBufQueue& buf,
std::unique_ptr<IOBuf>& result,
size_t&) override {
result = buf.move();
return result != nullptr;
}
示例3: decode
bool decode(Context*,
IOBufQueue& buf,
std::string& result,
size_t&) override {
if (buf.chainLength() > 0) {
result = buf.move()->moveToFbString().toStdString();
return true;
}
return false;
}
示例4: makeTestStruct
TEST(SerializationTest, DeserializeReturningObjGivenStringPiece) {
using serializer = SimpleJSONSerializer;
auto s = makeTestStruct();
IOBufQueue q;
serializer::serialize(s, &q);
auto b = q.move();
auto out = serializer::deserialize<TestStruct>(StringPiece(b->coalesce()));
EXPECT_EQ(s, out);
}
示例5: decode
bool LineBasedFrameDecoder::decode(Context* ctx,
IOBufQueue& buf,
std::unique_ptr<IOBuf>& result,
size_t&) {
int64_t eol = findEndOfLine(buf);
if (!discarding_) {
if (eol >= 0) {
Cursor c(buf.front());
c += eol;
auto delimLength = c.read<char>() == '\r' ? 2 : 1;
if (eol > maxLength_) {
buf.split(eol + delimLength);
fail(ctx, folly::to<std::string>(eol));
return false;
}
std::unique_ptr<folly::IOBuf> frame;
if (stripDelimiter_) {
frame = buf.split(eol);
buf.trimStart(delimLength);
} else {
frame = buf.split(eol + delimLength);
}
result = std::move(frame);
return true;
} else {
auto len = buf.chainLength();
if (len > maxLength_) {
discardedBytes_ = len;
buf.trimStart(len);
discarding_ = true;
fail(ctx, "over " + folly::to<std::string>(len));
}
return false;
}
} else {
if (eol >= 0) {
Cursor c(buf.front());
c += eol;
auto delimLength = c.read<char>() == '\r' ? 2 : 1;
buf.trimStart(eol + delimLength);
discardedBytes_ = 0;
discarding_ = false;
} else {
discardedBytes_ = buf.chainLength();
buf.move();
}
return false;
}
}
示例6: readBench
void readBench(size_t iters) {
BenchmarkSuspender susp;
auto strct = create<Struct>();
IOBufQueue q;
Serializer::serialize(strct, &q);
auto buf = q.move();
susp.dismiss();
while (iters--) {
Struct data;
Serializer::deserialize(buf.get(), data);
}
susp.rehire();
}
示例7: readBenchMemory
int readBenchMemory(size_t iters) {
auto strct = create<Struct>();
IOBufQueue q;
Serializer::serialize(strct, &q);
auto buf = q.move();
auto before = getMemoryRequestsCounter();
while (iters--) {
Struct data;
Serializer::deserialize(buf.get(), data);
}
auto after = getMemoryRequestsCounter();
return after - before;
}
示例8: sendImpl
void FastCGITransport::sendImpl(const void *data, int size, int code,
bool chunked) {
IOBufQueue queue;
if (!m_headersSent) {
sendResponseHeaders(queue, code);
}
queue.append(IOBuf::copyBuffer(data, size));
folly::MoveWrapper<std::unique_ptr<IOBuf>> chain_wrapper(queue.move());
Callback* callback = m_callback;
auto fn = [callback, chain_wrapper]() mutable {
if (callback) {
callback->onStdOut(std::move(*chain_wrapper));
}
};
m_connection->getEventBase()->runInEventBaseThread(fn);
}
示例9: read
void read(Context*, IOBufQueue& q) override {
backendPipeline_->write(q.move());
}
示例10: read
void read(Context* ctx, IOBufQueue& q) override {
frontendPipeline_->write(q.move());
}