Project

General

Profile

Actions

Feature #11517

open

Queue enhancement - conditional pop

Added by jonathanscruz (Jonathan Cruz) over 8 years ago. Updated 17 days ago.

Status:
Assigned
Target version:
-
[ruby-core:<unknown>]

Description

I’m 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 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) ruby_queue_conditional_pop.patch jonathanscruz (Jonathan Cruz), 09/09/2015 03:02 PM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0