File tree Expand file tree Collapse file tree 2 files changed +11
-7
lines changed
Expand file tree Collapse file tree 2 files changed +11
-7
lines changed Original file line number Diff line number Diff line change 88 "syscall"
99 "time"
1010
11+ "github.com/oxtoacart/bpool"
1112 "github.com/rcrowley/go-metrics"
1213 "github.com/sunvim/utils/netpoll"
1314)
@@ -23,9 +24,7 @@ func main() {
2324 }()
2425
2526 var handler = & netpoll.DataHandler {
26- NoShared : true ,
27- NoCopy : true ,
28- BufferSize : 1024 ,
27+ Pool : bpool .NewBytePool (1024 , 12 * 1024 ),
2928 HandlerFunc : func (req []byte ) (res []byte ) {
3029 res = req
3130 return
Original file line number Diff line number Diff line change 77 "errors"
88 "net"
99 "sync"
10-
11- "github.com/oxtoacart/bpool"
1210)
1311
1412// ErrHandlerFunc is the error when the HandlerFunc is nil
@@ -70,9 +68,16 @@ func (h *ConnHandler) Serve(ctx Context) error {
7068 return h .serve (ctx )
7169}
7270
71+ type BytePool interface {
72+ Get () []byte
73+ Put (b []byte )
74+ NumPooled () int
75+ Width () int
76+ }
77+
7378// DataHandler implements the Handler interface.
7479type DataHandler struct {
75- Pool * bpool. BytePool
80+ Pool BytePool
7681 upgrade func (net.Conn ) (net.Conn , error )
7782 // HandlerFunc is the data Serve function.
7883 HandlerFunc func (req []byte ) (res []byte )
@@ -83,7 +88,7 @@ type context struct {
8388 writing sync.Mutex
8489 upgrade bool
8590 conn net.Conn
86- pool * bpool. BytePool
91+ pool BytePool
8792 buffer []byte
8893}
8994
You can’t perform that action at this time.
0 commit comments