Skip to content

Commit

Permalink
framer: remove framerpool
Browse files Browse the repository at this point in the history
  • Loading branch information
Zariel committed May 22, 2018
1 parent 41a557b commit 8ffb77e
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 21 deletions.
7 changes: 0 additions & 7 deletions conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,6 @@ func (c *Conn) authenticateHandshake(ctx context.Context, authFrame *authenticat
default:
return fmt.Errorf("unknown frame response during authentication: %v", v)
}

framerPool.Put(framer)
}
}

Expand Down Expand Up @@ -479,7 +477,6 @@ func (c *Conn) recv() error {
if err := framer.readFrame(&head); err != nil {
return err
}
defer framerPool.Put(framer)

frame, err := framer.parseFrame()
if err != nil {
Expand Down Expand Up @@ -747,8 +744,6 @@ func (c *Conn) prepareStatement(ctx context.Context, stmt string, tracer Tracer)
c.session.stmtsLRU.remove(stmtCacheKey)
}

framerPool.Put(framer)

return flight.preparedStatment, flight.err
}

Expand Down Expand Up @@ -1046,7 +1041,6 @@ func (c *Conn) executeBatch(batch *Batch) *Iter {

switch x := resp.(type) {
case *resultVoidFrame:
framerPool.Put(framer)
return &Iter{}
case *RequestErrUnprepared:
stmt, found := stmts[string(x.StatementId)]
Expand All @@ -1056,7 +1050,6 @@ func (c *Conn) executeBatch(batch *Batch) *Iter {
}

if found {
framerPool.Put(framer)
return c.executeBatch(batch)
} else {
return &Iter{err: x, framer: framer}
Expand Down
2 changes: 0 additions & 2 deletions events.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ func (e *eventDebouncer) debounce(frame frame) {
}

func (s *Session) handleEvent(framer *framer) {
defer framerPool.Put(framer)

frame, err := framer.parseFrame()
if err != nil {
// TODO: logger
Expand Down
15 changes: 4 additions & 11 deletions frame.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"net"
"runtime"
"strings"
"sync"
"time"
)

Expand Down Expand Up @@ -346,15 +345,6 @@ func (f frameHeader) Header() frameHeader {

const defaultBufSize = 128

var framerPool = sync.Pool{
New: func() interface{} {
return &framer{
wbuf: make([]byte, defaultBufSize),
readBuffer: make([]byte, defaultBufSize),
}
},
}

// a framer is responsible for reading, writing and parsing frames on a single stream
type framer struct {
r io.Reader
Expand All @@ -380,7 +370,10 @@ type framer struct {
}

func newFramer(r io.Reader, w io.Writer, compressor Compressor, version byte) *framer {
f := framerPool.Get().(*framer)
f := &framer{
wbuf: make([]byte, defaultBufSize),
readBuffer: make([]byte, defaultBufSize),
}
var flags byte
if compressor != nil {
flags |= flagCompress
Expand Down
1 change: 0 additions & 1 deletion session.go
Original file line number Diff line number Diff line change
Expand Up @@ -1311,7 +1311,6 @@ func (iter *Iter) Warnings() []string {
func (iter *Iter) Close() error {
if atomic.CompareAndSwapInt32(&iter.closed, 0, 1) {
if iter.framer != nil {
framerPool.Put(iter.framer)
iter.framer = nil
}
}
Expand Down

0 comments on commit 8ffb77e

Please sign in to comment.