Thread::Queue::MaxSize - Thread-safe queues with an upper bound
This document describes Thread::Queue::MaxSize version 1.02
use strict; use warnings; use threads; use Thread::Queue::MaxSize; # create a new empty queue with no max limit my $q = Thread::Queue::MaxSize->new(); # create a new empty queue that will only ever store 1000 items my $q = Thread::Queue::MaxSize->new({ maxsize => 1000 }); # create a queue that will die when too many items are enqueued my $q = Thread::Queue::MaxSize->new({ maxsize => 1000, on_maxsize => 'die' });
This is a subclass to Thread::Queue that will enforce an upper bound on the number of items in a queue. This can be used to prevent memory use from exploding on a queue that might never empty.
Creates a new empty queue. This queue will have no items to start.
Creates a new empty queue with some options. The two configurable options are:
Defines the maximum size that the queue can ever be.
Defines the action that will be taken when a queue reaches its maximum size. There are five actions that can be taken when the list of items to enqueue or insert would cause the queue to go over its maximum size. In all cases either the all items are enqueued/inserted or none of the items are enqueued/inserted.
No items will be enqueued/inserted and the queue will throw an exception.
No items will be enqueued/inserted and the queue will issue a warning.
No items will be enqueued/inserted and no indication will be given as to why.
All items will be enqueued/inserted, the oldest items on the list will be truncated off the end, and the queue will issue a warning.
All items will be enqueued/insertd, the oldest items on the list will be truncated off the end, and no indication will be given as to why. This is the default action.
Thread::Queue, threads, threads::shared
Paul Lockaby <plockaby AT cpan DOT org>
Significant portions of this module are directly from Thread::Queue which is maintained by Jerry D. Hedden, <jdhedden AT cpan DOT org>.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
2 POD Errors
The following errors were encountered while parsing the POD:
=back doesn't take any parameters, but you said =back warn_and_truncate
=back doesn't take any parameters, but you said =back silent_truncate
To install Thread::Queue::MaxSize, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Thread::Queue::MaxSize
CPAN shell
perl -MCPAN -e shell install Thread::Queue::MaxSize
For more information on module installation, please visit the detailed CPAN module installation guide.