add Write method to autofile/Group

This commit is contained in:
Anton Kaliaev
2017-10-17 16:48:44 +04:00
parent 498fb1134a
commit 45095e83e7

View File

@@ -146,6 +146,17 @@ func (g *Group) MaxIndex() int {
return g.maxIndex
}
// Write writes the contents of p into the current head of the group. It
// returns the number of bytes written. If nn < len(p), it also returns an
// error explaining why the write is short.
// NOTE: Writes are buffered so they don't write synchronously
// TODO: Make it halt if space is unavailable
func (g *Group) Write(p []byte) (nn int, err error) {
g.mtx.Lock()
defer g.mtx.Unlock()
return g.headBuf.Write(p)
}
// WriteLine writes line into the current head of the group. It also appends "\n".
// NOTE: Writes are buffered so they don't write synchronously
// TODO: Make it halt if space is unavailable