Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch to using a generic pool for channels in Connection
Signed-off-by: Ed Warnicke <hagbard@gmail.com>
- Loading branch information
1 parent
822f517
commit 082a58b
Showing
5 changed files
with
72 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package genericpool | ||
|
||
import ( | ||
"sync" | ||
) | ||
|
||
type Pool[T any] struct { | ||
p sync.Pool | ||
} | ||
|
||
func (p *Pool[T]) Get() T { | ||
return p.p.Get().(T) | ||
} | ||
|
||
func (p *Pool[T]) Put(x T) { | ||
p.p.Put(x) | ||
} | ||
|
||
func New[T any](f func() T) *Pool[T] { | ||
return &Pool[T]{ | ||
p: sync.Pool{ | ||
New: func() any { return f() }, | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,23 @@ | ||
module go.fd.io/govpp | ||
|
||
go 1.13 | ||
go 1.18 | ||
|
||
require ( | ||
github.com/bennyscetbun/jsongo v1.1.0 | ||
github.com/fsnotify/fsnotify v1.4.9 | ||
github.com/ftrvxmtrx/fd v0.0.0-20150925145434-c6d800382fff | ||
github.com/kr/pretty v0.1.0 // indirect | ||
github.com/lunixbochs/struc v0.0.0-20200521075829-a4cb8d33dbbe | ||
github.com/onsi/gomega v1.19.0 | ||
github.com/pkg/profile v1.2.1 | ||
github.com/sirupsen/logrus v1.6.0 | ||
) | ||
|
||
require ( | ||
github.com/konsorten/go-windows-terminal-sequences v1.0.3 // indirect | ||
github.com/kr/pretty v0.1.0 // indirect | ||
golang.org/x/net v0.0.0-20220225172249-27dd8689420f // indirect | ||
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6 // indirect | ||
golang.org/x/text v0.3.7 // indirect | ||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect | ||
gopkg.in/yaml.v2 v2.4.0 // indirect | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters