Add pool support everywhere

This commit is contained in:
9seconds
2020-03-24 11:22:59 +03:00
parent 9125a29e79
commit 837d96dc43
13 changed files with 162 additions and 62 deletions
+11 -8
View File
@@ -28,15 +28,9 @@ func cloak(one, another io.ReadWriteCloser) {
wg.Add(2)
go func() {
defer wg.Done()
io.Copy(one, another) // nolint: errcheck
}()
go cloakPipe(one, another, wg)
go func() {
defer wg.Done()
io.Copy(another, one) // nolint: errcheck
}()
go cloakPipe(another, one, wg)
go func() {
wg.Wait()
@@ -69,3 +63,12 @@ func cloak(one, another io.ReadWriteCloser) {
<-ctx.Done()
}
func cloakPipe(one io.Writer, another io.Reader, wg *sync.WaitGroup) {
defer wg.Done()
buf := acquireCloakBuffer()
defer releaseCloakBuffer(buf)
io.CopyBuffer(one, another, *buf) // nolint: errcheck
}