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)
| 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. |
| 56 | func 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 | |
| 64 | func (s *lockedWriteSyncer) Write(bs []byte) (int, error) { |
| 65 | s.Lock() |
no outgoing calls