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