本文整理匯總了Golang中github.com/docker/libchan.Sender.Close方法的典型用法代碼示例。如果您正苦於以下問題:Golang Sender.Close方法的具體用法?Golang Sender.Close怎麽用?Golang Sender.Close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/docker/libchan.Sender
的用法示例。
在下文中一共展示了Sender.Close方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: BenchClient
func BenchClient(b *testing.B, c chan bool, sender libchan.Sender, sendFunc BenchMessageSender, count int) {
defer close(c)
for i := 0; i < count; i++ {
sendFunc(i, sender)
}
err := sender.Close()
if err != nil {
b.Fatalf("Error closing sender: %s", err)
}
}
示例2: copySender
func (c *channel) copySender(val libchan.Sender) (libchan.Sender, error) {
recv, send, err := c.CreateNestedReceiver()
if err != nil {
return nil, err
}
go func() {
libchan.Copy(val, recv)
val.Close()
}()
return send, nil
}
示例3: copySendChannel
func (c *channel) copySendChannel(send libchan.Sender) (*channel, error) {
recv, sendCopy, err := c.CreateNestedReceiver()
if err != nil {
return nil, err
}
// Start copying into sender
go func() {
libchan.Copy(send, recv)
send.Close()
}()
return sendCopy.(*channel), nil
}
示例4: BenchProxy
func BenchProxy(b *testing.B, c chan bool, sender libchan.Sender, receiver libchan.Receiver, count int) {
defer close(c)
n, err := libchan.Copy(sender, receiver)
if err != nil {
b.Errorf("Error proxying: %s", err)
}
err = sender.Close()
if err != nil {
b.Errorf("Error closing sender: %s", err)
}
if n != count {
b.Errorf("Wrong proxy count\n\tExpected: %d\n\tActual: %d", count, n)
}
}