Improve documentation wording for SyncWriter (#235)

There is already a lock in place for both POSIX (Linux/Unix/Darwin) and Windows, see:

https://github.com/golang/go/blob/go1.14.3/src/internal/poll/fd_windows.go#L684
https://github.com/golang/go/blob/go1.14.3/src/internal/poll/fd_unix.go#L255
This commit is contained in:
Giuseppe 2020-05-25 19:57:14 +02:00 committed by GitHub
parent 663cbb4c84
commit f83de79b81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 5 deletions

View File

@ -26,11 +26,9 @@ type syncWriter struct {
} }
// SyncWriter wraps w so that each call to Write is synchronized with a mutex. // SyncWriter wraps w so that each call to Write is synchronized with a mutex.
// This syncer can be the call to writer's Write method is not thread safe. // This syncer can be used to wrap the call to writer's Write method if it is
// Note that os.File Write operation is using write() syscall which is supposed // not thread safe. Note that you do not need this wrapper for os.File Write
// to be thread-safe on POSIX systems. So there is no need to use this with // operations on POSIX and Windows systems as they are already thread-safe.
// os.File on such systems as zerolog guarantees to issue a single Write call
// per log event.
func SyncWriter(w io.Writer) io.Writer { func SyncWriter(w io.Writer) io.Writer {
if lw, ok := w.(LevelWriter); ok { if lw, ok := w.(LevelWriter); ok {
return &syncWriter{lw: lw} return &syncWriter{lw: lw}