MCPcopy
hub / github.com/uber-go/zap / Lock

Function Lock

zapcore/write_syncer.go:56–62  ·  view source on GitHub ↗

Lock wraps a WriteSyncer in a mutex to make it safe for concurrent use. In particular, *os.Files must be locked before use.

(ws WriteSyncer)

Source from the content-addressed store, hash-verified

54// Lock wraps a WriteSyncer in a mutex to make it safe for concurrent use. In
55// particular, *os.Files must be locked before use.
56func Lock(ws WriteSyncer) WriteSyncer {
57 if _, ok := ws.(*lockedWriteSyncer); ok {
58 // no need to layer on another lock
59 return ws
60 }
61 return &lockedWriteSyncer{ws: ws}
62}
63
64func (s *lockedWriteSyncer) Write(bs []byte) (int, error) {
65 s.Lock()

Callers 8

TestLoggerWriteFailureFunction · 0.92
NewFunction · 0.92
ExampleAtomicLevelFunction · 0.92
CombineWriteSyncersFunction · 0.92
TestIOCoreWriteFailureFunction · 0.85
TestBufferWriterFunction · 0.85

Calls

no outgoing calls

Tested by 6

TestLoggerWriteFailureFunction · 0.74
ExampleAtomicLevelFunction · 0.74
TestIOCoreWriteFailureFunction · 0.68
TestBufferWriterFunction · 0.68