MCPcopy
hub / github.com/subtrace/subtrace / Lock

Method Lock

cmd/run/fd/fd.go:152–165  ·  view source on GitHub ↗

Lock waits until there is exactly one pending ref (the caller's). It panics if the *fd.FD isn't already in the closed state. In most situations, Lock should be called after the ClosingIncRef and before the close(2) syscall.

()

Source from the content-addressed store, hash-verified

150// if the *fd.FD isn't already in the closed state. In most situations, Lock
151// should be called after the ClosingIncRef and before the close(2) syscall.
152func (fd *FD) Lock() {
153 refs := atomic.LoadUint32(&fd.refs)
154 left := refs &^ uint32(flagClosed)
155 if refs&flagClosed == 0 {
156 panic("Lock called without marking file as closed")
157 }
158 if DEBUG {
159 fmt.Printf("%p: %s: Lock: left=%d, closed=%v\n", fd, fd.String(), left, refs&flagClosed)
160 }
161 if left > 1 {
162 // The last non-closing DecRef will do a semrelease.
163 semacquire(&fd.sema)
164 }
165}
166
167//go:linkname semacquire sync.runtime_Semacquire
168func semacquire(addr *uint32)

Callers 15

addMethod · 0.80
removeMethod · 0.80
SendEventMethod · 0.80
addConnMethod · 0.80
removeConnMethod · 0.80
sendMethod · 0.80
resetMethod · 0.80
insertMethod · 0.80
flushOnceMethod · 0.80
waitProcessMethod · 0.80
getProcessMethod · 0.80
CloseMethod · 0.80

Calls 2

StringMethod · 0.95
semacquireFunction · 0.85

Tested by

no test coverage detected