func (x *pair) AddEndpoint(ep mangos.Endpoint) { x.Lock() if x.peer != nil { x.Unlock() ep.Close() return } x.peer = ep x.Unlock() x.senders.Add() go x.receiver(ep) go x.sender(ep) }
func (x *resp) AddEndpoint(ep mangos.Endpoint) { x.Lock() if x.peer != nil { x.Unlock() ep.Close() return } peer := &respPeer{ep: ep, x: x, q: make(chan *mangos.Message, 1)} x.peer = peer x.Unlock() x.senders.Add() go peer.receiver() go peer.sender() }
func (x *pair) AddEndpoint(ep mangos.Endpoint) { peer := &pairEp{cq: make(chan struct{}), ep: ep} x.Lock() if x.peer != nil { // We already have a connection, reject this one. x.Unlock() ep.Close() return } x.peer = peer x.Unlock() x.w.Add() go x.receiver(peer) go x.sender(peer) }