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

Method Release

nocopy_linkbuffer.go:925–939  ·  view source on GitHub ↗

Release consists of two parts: 1. reduce the reference count of itself and origin. 2. recycle the buf when the reference count is 0.

()

Source from the content-addressed store, hash-verified

923// 1. reduce the reference count of itself and origin.
924// 2. recycle the buf when the reference count is 0.
925func (node *linkBufferNode) Release() (err error) {
926 if node.origin != nil {
927 node.origin.Release()
928 }
929 // release self
930 if atomic.AddInt32(&node.refer, -1) == 0 {
931 // readonly nodes cannot recycle node.buf, other node.buf are recycled to mcache.
932 if node.reusable() {
933 free(node.buf)
934 }
935 node.buf, node.origin, node.next = nil, nil, nil
936 linkedPool.Put(node)
937 }
938 return nil
939}
940
941func (node *linkBufferNode) getFlag(flag uint8) bool {
942 return node.mode&flag > 0

Callers 1

Calls 3

reusableMethod · 0.95
freeFunction · 0.85
ReleaseMethod · 0.65

Tested by 1