File tree Expand file tree Collapse file tree 2 files changed +20
-6
lines changed Expand file tree Collapse file tree 2 files changed +20
-6
lines changed Original file line number Diff line number Diff line change @@ -125,13 +125,16 @@ def limited?
125
125
# If the queue is full, this method will block until there is space available.
126
126
#
127
127
# @parameter item [Object] The item to add to the queue.
128
- def << ( item )
128
+ def push ( item )
129
129
while limited?
130
130
@full . wait
131
131
end
132
132
133
133
super
134
134
end
135
+
136
+ # Compatibility with {::Queue#push}.
137
+ alias << push
135
138
136
139
# Add multiple items to the queue.
137
140
#
@@ -163,5 +166,8 @@ def dequeue
163
166
164
167
return item
165
168
end
169
+
170
+ # Compatibility with {::Queue#pop}.
171
+ alias pop dequeue
166
172
end
167
173
end
Original file line number Diff line number Diff line change @@ -244,13 +244,21 @@ def before
244
244
queue << :item2
245
245
end
246
246
247
- reactor . async do |task |
248
- task . sleep 0.01
249
- expect ( queue . items ) . to contain_exactly :item1
250
- queue . dequeue
251
- expect ( queue . items ) . to contain_exactly :item2
247
+ expect ( queue . dequeue ) . to be == :item1
248
+ expect ( queue . dequeue ) . to be == :item2
249
+ end
250
+
251
+ with "#pop" do
252
+ it "waits until a queue is dequeued" do
253
+ reactor . async do
254
+ queue << :item2
255
+ end
256
+
257
+ expect ( queue . pop ) . to be == :item1
258
+ expect ( queue . pop ) . to be == :item2
252
259
end
253
260
end
254
261
end
255
262
end
256
263
end
264
+
You can’t perform that action at this time.
0 commit comments