Term::MultiSpinner - Term::Spinner with multiple spinners
use Term::MultiSpinner; my $spinner = Term::MultiSpinner->new(); while(... a complicated async loop ...) { if(... can read some data ...) { $spinner->advance(0); # read stuff $spinner->finish(0) if $done_reading; } if(... can write some data ...) { $spinner->advance(1); # write stuff $spinner->finish(1) if $done_writing; } } undef $spinner; # clears final spinner output by default.
This is a subclass of Term::Spinner, see those docs first.
This class provides multiple spinners on the same line, to represent the state of several asynchronous long-running tasks. Ideal for a complex select-based loop, a POE process, etc.
select
Another good place to use it is if you have a long queue of short tasks to complete and can only do a small number in parallel at a time. Use the first spinner to indicate when a task is taken from the queue and started, and the second spinner to indicate task completion.
The docs below only indicate deviations from the interface of Term::Spinner, see those docs for the basic information.
Requires an argument, which is the integer spinner slot to advance. The first spinner is 0. The number of spinners on the screen will always automagically expand to include the entire range of 0 through the highest number you've directly accessed.
0
Requires an argument, which is the integer spinner slot to finish. The first spinner is 0. The number of spinners on the screen will always automagically expand to include the entire range of 0 through the highest number you've directly accessed.
Calls "advance" on all spinners.
Calls "finish" on all spinners.
Brandon L. Black, <blblack@gmail.com>
Copyright 2007 Brandon L. Black
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Term::Spinner, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Term::Spinner
CPAN shell
perl -MCPAN -e shell install Term::Spinner
For more information on module installation, please visit the detailed CPAN module installation guide.