File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -32,10 +32,10 @@ function Condvar:notify_all()
3232 callback ()
3333 end
3434
35- for i = 1 , len do
35+ for _ = 1 , len do
3636 -- table.remove will ensure that indexes are correct and make "ipairs" safe,
3737 -- which is not the case for "self.handles[i] = nil"
38- table.remove (self .handles , i )
38+ table.remove (self .handles )
3939 end
4040end
4141
Original file line number Diff line number Diff line change @@ -125,4 +125,34 @@ describe("condvar", function()
125125
126126 eq (3 , counter )
127127 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 )
128158end )
You can’t perform that action at this time.
0 commit comments