File tree Expand file tree Collapse file tree 2 files changed +32
-2
lines changed Expand file tree Collapse file tree 2 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -32,10 +32,10 @@ function Condvar:notify_all()
32
32
callback ()
33
33
end
34
34
35
- for i = 1 , len do
35
+ for _ = 1 , len do
36
36
-- table.remove will ensure that indexes are correct and make "ipairs" safe,
37
37
-- which is not the case for "self.handles[i] = nil"
38
- table.remove (self .handles , i )
38
+ table.remove (self .handles )
39
39
end
40
40
end
41
41
Original file line number Diff line number Diff line change @@ -125,4 +125,34 @@ describe("condvar", function()
125
125
126
126
eq (3 , counter )
127
127
end )
128
+
129
+ a .it (" notify all works multiple times" , function ()
130
+ local condvar = Condvar .new ()
131
+ local counter = 0
132
+
133
+ a .run (function ()
134
+ condvar :wait ()
135
+ counter = counter + 1
136
+ end )
137
+
138
+ a .run (function ()
139
+ condvar :wait ()
140
+ counter = counter + 1
141
+ end )
142
+
143
+ eq (0 , counter )
144
+
145
+ condvar :notify_all ()
146
+
147
+ eq (2 , counter )
148
+
149
+ a .run (function ()
150
+ condvar :wait ()
151
+ counter = 0
152
+ end )
153
+
154
+ condvar :notify_all ()
155
+
156
+ eq (0 , counter )
157
+ end )
128
158
end )
You can’t perform that action at this time.
0 commit comments