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

Method Refer

nocopy_linkbuffer.go:909–920  ·  view source on GitHub ↗

Refer holds a reference count at the same time as Next, and releases the real buffer after Release. The node obtained by Refer is read-only.

(n int)

Source from the content-addressed store, hash-verified

907// Refer holds a reference count at the same time as Next, and releases the real buffer after Release.
908// The node obtained by Refer is read-only.
909func (node *linkBufferNode) Refer(n int) (p *linkBufferNode) {
910 p = newLinkBufferNode(0)
911 p.buf = node.Next(n)
912
913 if node.origin != nil {
914 p.origin = node.origin
915 } else {
916 p.origin = node
917 }
918 atomic.AddInt32(&p.origin.refer, 1)
919 return p
920}
921
922// Release consists of two parts:
923// 1. reduce the reference count of itself and origin.

Callers 1

SliceMethod · 0.80

Calls 2

NextMethod · 0.95
newLinkBufferNodeFunction · 0.85

Tested by

no test coverage detected