本文整理汇总了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)
}
}