MCPcopy Create free account
hub / github.com/cloudwego/netpoll / book

Method book

nocopy_linkbuffer.go:702–714  ·  view source on GitHub ↗

book will grow and malloc buffer to hold data. bookSize: The size of data that can be read at once. maxSize: The maximum size of data between two Release(). In some cases, this can guarantee all data allocated in one node to reduce copy.

(bookSize, maxSize int)

Source from the content-addressed store, hash-verified

700//
701// guarantee all data allocated in one node to reduce copy.
702func (b *UnsafeLinkBuffer) book(bookSize, maxSize int) (p []byte) {
703 l := cap(b.write.buf) - b.write.malloc
704 // grow linkBuffer
705 if l == 0 {
706 l = maxSize
707 b.write.next = newLinkBufferNode(maxSize)
708 b.write = b.write.next
709 }
710 if l > bookSize {
711 l = bookSize
712 }
713 return b.write.Malloc(l)
714}
715
716// bookAck will ack the first n malloc bytes and discard the rest.
717//

Callers 4

TestLinkBufferFunction · 0.45
TestLinkBufferMultiNodeFunction · 0.45
TestLinkBufferReferFunction · 0.45
inputsMethod · 0.45

Calls 2

newLinkBufferNodeFunction · 0.85
MallocMethod · 0.65

Tested by 3

TestLinkBufferFunction · 0.36
TestLinkBufferMultiNodeFunction · 0.36
TestLinkBufferReferFunction · 0.36