[ruby-core:70730] [Ruby trunk - Feature #11517] Queue enhancement - conditional pop

From: funny.falcon@...
Date: 2015-09-12 09:08:23 UTC
List: ruby-core #70730
Issue #11517 has been updated by Yura Sokolov.


Why don't you use separate queue with separate worker? It will solve your u=
se case.

Even if it is hard to separate jobs before put into main queue,  workers co=
uld push such heavy tasks into separate queue after fetching it from main q=
ueue.

----------------------------------------
Feature #11517: Queue enhancement - conditional pop
https://bugs.ruby-lang.org/issues/11517#change-54109

* Author: Jonathan Cruz
* Status: Open
* Priority: Normal
* Assignee: Yukihiro Matsumoto
----------------------------------------
I=E2=80=99m submitting a patch to enhance Queue#pop. This allows the caller=
 to provide a block that accepts data from the queue. Queue#pop will return=
 the first element for which the block returns a truthy value, and remove i=
t from the queue. Without a block, Queue#pop will behave the same way it cu=
rrently does.

The motivation for this enhancement: On our project, we have a queue of wor=
k and several worker threads. Some work can incur a heavy load on the syste=
m and should not be processed while another worker is processing 'heavy loa=
d' work. We need a way for Queue#pop to skip over heavy load items while an=
other thread is processing heavy load work.

---Files--------------------------------
ruby_queue_conditional_pop.patch (3.76 KB)


--=20
https://bugs.ruby-lang.org/

In This Thread

Prev Next