Commit bbdb2ba8 authored by Vladimir Barsukov's avatar Vladimir Barsukov
Browse files

add lock/unlock

parent 9a2dfae3
......@@ -2,6 +2,7 @@ package zbytes
import (
"bytes"
"fmt"
"sync"
)
......@@ -41,6 +42,9 @@ func (z *Buffer) WriteString(s string) (n int, err error) {
return z.Buff.WriteString(s)
}
func (z *Buffer) WriteAny(a any) (n int, err error) {
return z.WriteString(fmt.Sprintf("%v", a))
}
func (z *Buffer) Bytes() []byte {
z.Mu.Lock()
......@@ -48,14 +52,12 @@ func (z *Buffer) Bytes() []byte {
return z.Buff.Bytes()
}
func (z *Buffer) String() string {
z.Mu.Lock()
defer z.Mu.Unlock()
return z.Buff.String()
}
func (z *Buffer) Reset() {
z.Mu.Lock()
defer z.Mu.Unlock()
......@@ -68,3 +70,10 @@ func (z *Buffer) Len() int {
return z.Buff.Len()
}
func (z *Buffer) Lock() {
z.Mu.Lock()
}
func (z *Buffer) Unlock() {
z.Mu.Unlock()
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment