Skip Menu |

This queue is for tickets about the Thread-Queue CPAN distribution.

Report information
The Basics
Id: 106533
Status: resolved
Priority: 0/
Queue: Thread-Queue

People
Owner: Nobody in particular
Requestors: mark [...] markandruth.co.uk
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 3.06



Subject: Feature request: Limit queue size
Date: Wed, 19 Aug 2015 12:47:32 +0300
To: bug-Thread-Queue [...] rt.cpan.org
From: Mark Zealey <mark [...] markandruth.co.uk>
I frequently find myself writing code such as: while( my $item = fetch_item ) { while ( $q->pending > 1000 ) { usleep 0.1; } $q->enqueue( $item ) } May I request a feature something like $q->set_max_size( 1000 ); # 0 for unlimited (default to maintain backwards compatibility) $q->set_max_size_poll_interval( 0.1 ); # Default this to something sensible which would do the same ie ->enqueue polls every X seconds until there is space in the queue? Otherwise you can easily exhaust memory if for some reason threads are unable to keep up with the work assigned. Thanks! Mark
I have added a limit feature to version 3.06 which is now available on CPAN. On 2015-08-19 05:47:47, mark@markandruth.co.uk wrote: Show quoted text
> I frequently find myself writing code such as: > > while( my $item = fetch_item ) { > while ( $q->pending > 1000 ) { > usleep 0.1; > } > $q->enqueue( $item ) > } > > May I request a feature something like > > $q->set_max_size( 1000 ); # 0 for unlimited (default to maintain > backwards compatibility) > $q->set_max_size_poll_interval( 0.1 ); # Default this to something > sensible > > which would do the same ie ->enqueue polls every X seconds until there > is space in the queue? > > Otherwise you can easily exhaust memory if for some reason threads are > unable to keep up with the work assigned. > > Thanks! > > Mark