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