forked from hashicorp/go-memdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
watch_few.go
117 lines (80 loc) · 1.39 KB
/
watch_few.go
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
117
package memdb
//go:generate sh -c "go run watch-gen/main.go >watch_few.go"
import(
"context"
)
// 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(ctx context.Context, ch []<-chan struct{}) error {
select {
case <-ch[0]:
return nil
case <-ch[1]:
return nil
case <-ch[2]:
return nil
case <-ch[3]:
return nil
case <-ch[4]:
return nil
case <-ch[5]:
return nil
case <-ch[6]:
return nil
case <-ch[7]:
return nil
case <-ch[8]:
return nil
case <-ch[9]:
return nil
case <-ch[10]:
return nil
case <-ch[11]:
return nil
case <-ch[12]:
return nil
case <-ch[13]:
return nil
case <-ch[14]:
return nil
case <-ch[15]:
return nil
case <-ch[16]:
return nil
case <-ch[17]:
return nil
case <-ch[18]:
return nil
case <-ch[19]:
return nil
case <-ch[20]:
return nil
case <-ch[21]:
return nil
case <-ch[22]:
return nil
case <-ch[23]:
return nil
case <-ch[24]:
return nil
case <-ch[25]:
return nil
case <-ch[26]:
return nil
case <-ch[27]:
return nil
case <-ch[28]:
return nil
case <-ch[29]:
return nil
case <-ch[30]:
return nil
case <-ch[31]:
return nil
case <-ctx.Done():
return ctx.Err()
}
}