MCPcopy Create free account
hub / github.com/apple/foundationdb / writeAhead

Method writeAhead

flow/Net2Packet.cpp:77–92  ·  view source on GitHub ↗

Adds exactly bytes of unwritten length to the buffer, possibly across packet buffer boundaries, and initializes buf to point to the packet buffer(s) that contain the unwritten space

Source from the content-addressed store, hash-verified

75// Adds exactly bytes of unwritten length to the buffer, possibly across packet buffer boundaries,
76// and initializes buf to point to the packet buffer(s) that contain the unwritten space
77void PacketWriter::writeAhead(int bytes, struct SplitBuffer* buf) {
78 if (bytes <= buffer->bytes_unwritten()) {
79 buf->begin = buffer->data() + buffer->bytes_written;
80 buf->first_length = bytes;
81 buffer->bytes_written += bytes;
82 buf->next = 0;
83 } else {
84 buf->begin = buffer->data() + buffer->bytes_written;
85 buf->first_length = buffer->bytes_unwritten();
86 buffer->bytes_written = buffer->size();
87 size_t remaining = bytes - buf->first_length;
88 nextBuffer(remaining);
89 buf->next = buffer->data();
90 buffer->bytes_written = remaining;
91 }
92}
93
94void SplitBuffer::write(const void* data, int len) {
95 write(data, len, 0);

Callers 1

sendPacketFunction · 0.80

Calls 3

bytes_unwrittenMethod · 0.80
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected