blob: 53b2ebde51e1ca7d49b5d65581664e74ac4330d6 [file] [log] [blame]
Josh Bleecher Snyder604455a2017-03-15 11:27:26 -07001// compile
2
3// Copyright 2017 The Go Authors. All rights reserved.
4// Use of this source code is governed by a BSD-style
5// license that can be found in the LICENSE file.
6
7package p
8
9type NodeLink struct{}
10
11// A role our end of NodeLink is intended to play
12type LinkRole int64
13
14const (
15 LinkServer LinkRole = iota // link created as server
16 LinkClient // link created as client
17
18 // for testing:
19 linkNoRecvSend LinkRole = 1 << 16 // do not spawn serveRecv & serveSend
20 linkFlagsMask LinkRole = (1<<32 - 1) << 16
21)
22
23func NewNodeLink(role LinkRole) *NodeLink {
24 var nextConnId uint32
25 switch role &^ linkFlagsMask {
26 case LinkServer:
27 nextConnId = 0 // all initiated by us connId will be even
28 case LinkClient:
29 nextConnId = 1 // ----//---- odd
30 default:
31 panic("invalid conn role")
32 }
33
34 _ = nextConnId
35 return nil
36}