File: watch_few.go

package info (click to toggle)
golang-github-hashicorp-go-memdb 0.0~git20170123.0.c01f56b-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 204 kB
  • ctags: 159
  • sloc: makefile: 5
file content (116 lines) | stat: -rw-r--r-- 1,485 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
//go:generate sh -c "go run watch-gen/main.go >watch_few.go"
package memdb

import(
	"time"
)

// aFew gives how many watchers this function is wired to support. You must
// always pass a full slice of this length, but unused channels can be nil.
const aFew = 32

// watchFew is used if there are only a few watchers as a performance
// optimization.
func watchFew(ch []<-chan struct{}, timeoutCh <-chan time.Time) bool {
	select {

	case <-ch[0]:
		return false

	case <-ch[1]:
		return false

	case <-ch[2]:
		return false

	case <-ch[3]:
		return false

	case <-ch[4]:
		return false

	case <-ch[5]:
		return false

	case <-ch[6]:
		return false

	case <-ch[7]:
		return false

	case <-ch[8]:
		return false

	case <-ch[9]:
		return false

	case <-ch[10]:
		return false

	case <-ch[11]:
		return false

	case <-ch[12]:
		return false

	case <-ch[13]:
		return false

	case <-ch[14]:
		return false

	case <-ch[15]:
		return false

	case <-ch[16]:
		return false

	case <-ch[17]:
		return false

	case <-ch[18]:
		return false

	case <-ch[19]:
		return false

	case <-ch[20]:
		return false

	case <-ch[21]:
		return false

	case <-ch[22]:
		return false

	case <-ch[23]:
		return false

	case <-ch[24]:
		return false

	case <-ch[25]:
		return false

	case <-ch[26]:
		return false

	case <-ch[27]:
		return false

	case <-ch[28]:
		return false

	case <-ch[29]:
		return false

	case <-ch[30]:
		return false

	case <-ch[31]:
		return false

	case <-timeoutCh:
		return true
	}
}