mirror of
https://github.com/ipfs/kubo.git
synced 2025-07-02 03:28:25 +08:00
moved pipes package
This commit is contained in:
16
Godeps/_workspace/src/github.com/jbenet/go-msgio/chan.go
generated
vendored
16
Godeps/_workspace/src/github.com/jbenet/go-msgio/chan.go
generated
vendored
@ -13,7 +13,15 @@ type Chan struct {
|
||||
BufPool *sync.Pool
|
||||
}
|
||||
|
||||
func NewChan(chanSize int, pool *sync.Pool) *Chan {
|
||||
func NewChan(chanSize int) *Chan {
|
||||
return &Chan{
|
||||
MsgChan: make(chan []byte, chanSize),
|
||||
ErrChan: make(chan error, 1),
|
||||
CloseChan: make(chan bool, 2),
|
||||
}
|
||||
}
|
||||
|
||||
func NewChanWithPool(chanSize int, pool *sync.Pool) *Chan {
|
||||
return &Chan{
|
||||
MsgChan: make(chan []byte, chanSize),
|
||||
ErrChan: make(chan error, 1),
|
||||
@ -26,6 +34,12 @@ func (s *Chan) ReadFrom(r io.Reader, maxMsgLen int) {
|
||||
// new buffer per message
|
||||
// if bottleneck, cycle around a set of buffers
|
||||
mr := NewReader(r)
|
||||
if s.BufPool == nil {
|
||||
s.BufPool = new(sync.Pool)
|
||||
s.BufPool.New = func() interface{} {
|
||||
return make([]byte, maxMsgLen)
|
||||
}
|
||||
}
|
||||
Loop:
|
||||
for {
|
||||
bufi := s.BufPool.Get()
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
|
||||
peer "github.com/jbenet/go-ipfs/peer"
|
||||
|
||||
pipes "github.com/jbenet/go-ipfs/pipes"
|
||||
pipes "github.com/jbenet/go-ipfs/util/pipes"
|
||||
)
|
||||
|
||||
// SecurePipe objects represent a bi-directional message channel.
|
||||
|
@ -11,7 +11,7 @@ import (
|
||||
ci "github.com/jbenet/go-ipfs/crypto"
|
||||
pb "github.com/jbenet/go-ipfs/crypto/spipe/internal/pb"
|
||||
"github.com/jbenet/go-ipfs/peer"
|
||||
"github.com/jbenet/go-ipfs/pipes"
|
||||
"github.com/jbenet/go-ipfs/util/pipes"
|
||||
)
|
||||
|
||||
type SignedPipe struct {
|
||||
|
@ -51,8 +51,8 @@ type msgioPipe struct {
|
||||
|
||||
func newMsgioPipe(size int, pool *sync.Pool) *msgioPipe {
|
||||
return &msgioPipe{
|
||||
outgoing: msgio.NewChan(size, nil),
|
||||
incoming: msgio.NewChan(size, pool),
|
||||
outgoing: msgio.NewChan(size),
|
||||
incoming: msgio.NewChanWithPool(size, pool),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,8 +8,8 @@ import (
|
||||
|
||||
spipe "github.com/jbenet/go-ipfs/crypto/spipe"
|
||||
peer "github.com/jbenet/go-ipfs/peer"
|
||||
"github.com/jbenet/go-ipfs/pipes"
|
||||
ctxc "github.com/jbenet/go-ipfs/util/ctxcloser"
|
||||
"github.com/jbenet/go-ipfs/util/pipes"
|
||||
)
|
||||
|
||||
// secureConn wraps another Conn object with an encrypted channel.
|
||||
|
Reference in New Issue
Block a user