[ruby-core:70729] Re: [Ruby trunk - Feature #11517] [Open] Queue enhancement - conditional pop

From: Юрий Соколов <funny.falcon@...>
Date: 2015-09-12 09:07:14 UTC
List: ruby-core #70729
Why don't you use separate queue with separate worker? It will solve your
use case.

Even if it is hard to separate jobs before put into main queue,  workers
could push such heavy tasks into separate queue after fetching it from main
queue.
09 =D1=81=D0=B5=D0=BD=D1=82. 2015 =D0=B3. 18:03 =D0=BF=D0=BE=D0=BB=D1=8C=D0=
=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C <jonathanscruz@yahoo.com> =D0=
=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:

> Issue #11517 has been reported by Jonathan Cruz.
>
> ----------------------------------------
> Feature #11517: Queue enhancement - conditional pop
> https://bugs.ruby-lang.org/issues/11517
>
> * Author: Jonathan Cruz
> * Status: Open
> * Priority: Normal
> * Assignee: Yukihiro Matsumoto
> ----------------------------------------
> I=E2=80=99m submitting a patch to enhance Queue#pop. This allows the call=
er to
> provide a block that accepts data from the queue. Queue#pop will return t=
he
> first element for which the block returns a truthy value, and remove it
> from the queue. Without a block, Queue#pop will behave the same way it
> currently does.
>
> The motivation for this enhancement: On our project, we have a queue of
> work and several worker threads. Some work can incur a heavy load on the
> system and should not be processed while another worker is processing
> 'heavy load' work. We need a way for Queue#pop to skip over heavy load
> items while another thread is processing heavy load work.
>
> ---Files--------------------------------
> ruby_queue_conditional_pop.patch (3.76 KB)
>
>
> --
> https://bugs.ruby-lang.org/
>

In This Thread

Prev Next