Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

buffer internal channels #189

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions rpc/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func newFramedMsgpackEncoder(maxFrameLength int32, writer io.Writer) *framedMsgp
maxFrameLength: maxFrameLength,
handle: newCodecMsgpackHandle(),
writer: writer,
writeCh: make(chan writeBundle),
writeCh: make(chan writeBundle, 100),
doneCh: make(chan struct{}),
closedCh: make(chan struct{}),
compressorCacher: newCompressorCacher(),
Expand Down Expand Up @@ -138,11 +138,13 @@ func (e *framedMsgpackEncoder) writerLoop() {
close(e.closedCh)
return
case write := <-e.writeCh:
if write.sn != nil {
write.sn()
}
_, err := e.writer.Write(write.bytes)
write.ch <- err
go func() {
if write.sn != nil {
write.sn()
}
_, err := e.writer.Write(write.bytes)
write.ch <- err
}()
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions rpc/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ func newReceiveHandler(enc *framedMsgpackEncoder, protHandler *protocolHandler,
stopCh: make(chan struct{}),
closedCh: make(chan struct{}),

taskBeginCh: make(chan *task),
taskCancelCh: make(chan SeqNumber),
taskEndCh: make(chan SeqNumber),
taskBeginCh: make(chan *task, 100),
taskCancelCh: make(chan SeqNumber, 100),
taskEndCh: make(chan SeqNumber, 100),

log: l,
}
Expand Down