MCPcopy
hub / github.com/rs/zerolog / SyncWriter

Function SyncWriter

writer.go:48–53  ·  view source on GitHub ↗

SyncWriter wraps w so that each call to Write is synchronized with a mutex. This syncer can be used to wrap the call to writer's Write method if it is not thread safe. Note that you do not need this wrapper for os.File Write operations on POSIX and Windows systems as they are already thread-safe.

(w io.Writer)

Source from the content-addressed store, hash-verified

46// not thread safe. Note that you do not need this wrapper for os.File Write
47// operations on POSIX and Windows systems as they are already thread-safe.
48func SyncWriter(w io.Writer) io.Writer {
49 if lw, ok := w.(LevelWriter); ok {
50 return &syncWriter{lw: lw}
51 }
52 return &syncWriter{lw: LevelWriterAdapter{w}}
53}
54
55// Write implements the io.Writer interface.
56func (s *syncWriter) Write(p []byte) (n int, err error) {

Callers 1

TestSyncWriterFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestSyncWriterFunction · 0.68