Ejemplo n.º 1
0
func NewTransport(frame trace.Frame, sub *codec.Transport) *Transport {
	t := &Transport{
		frame:  frame,
		sub:    sub,
		Dialer: NewDialer(frame.Refine("dialer"), sub),
	}
	frame.Bind(t)
	return t
}
Ejemplo n.º 2
0
func NewConn(frame trace.Frame, under *chain.Conn) *Conn {
	c := &Conn{
		frame: frame,
		// Only 1 needed in readLoop; get 3 just to be safe
		rch: make(chan interface{}, 3),
		// Capacity 1 (below) unblocks writeSync, invoked in readLoop right after a connection stitch
		// stitch is received, racing with a user write waiting on waitForLink.
		// In particular, if execUserWrite is waiting on waitForLink, it would prevent readLoop from
		// moving on to adopt the new connection.
		sch: make(chan *control, 1),
		ach: make(chan struct{}),
		sub: under,
		bfr: NewBuffer(frame.Refine("buffer"), MemoryCap),
	}
	c.frame.Bind(c)
	go c.readLoop()
	go c.writeLoop() // write loop for user and sync messages
	return c
}