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

Function newLinkBufferNode

nocopy_linkbuffer.go:842–855  ·  view source on GitHub ↗

------------------------------------------ implement link node ------------------------------------------ newLinkBufferNode create or reuse linkBufferNode. Nodes with size <= 0 are marked as readonly, which means the node.buf is not allocated by this mcache.

(size int)

Source from the content-addressed store, hash-verified

840// newLinkBufferNode create or reuse linkBufferNode.
841// Nodes with size <= 0 are marked as readonly, which means the node.buf is not allocated by this mcache.
842func newLinkBufferNode(size int) *linkBufferNode {
843 node := linkedPool.Get().(*linkBufferNode)
844 // reset node offset
845 node.off, node.malloc, node.refer, node.mode = 0, 0, 1, defaultLinkBufferMode
846 if size <= 0 {
847 node.setFlag(flagUnmanaged)
848 return node
849 }
850 if size < LinkBufferCap {
851 size = LinkBufferCap
852 }
853 node.buf = malloc(0, size)
854 return node
855}
856
857var linkedPool = sync.Pool{
858 New: func() interface{} {

Callers 10

NewLinkBufferFunction · 0.85
FlushMethod · 0.85
WriteBinaryMethod · 0.85
WriteDirectMethod · 0.85
bookMethod · 0.85
resetTailMethod · 0.85
growthMethod · 0.85
ReferMethod · 0.85
TestLinkBufferBufferModeFunction · 0.85

Calls 2

mallocFunction · 0.85
setFlagMethod · 0.80

Tested by 2

TestLinkBufferBufferModeFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…