The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Sub::Throttle - Throttle load of perl function

SYNOPSIS

  use Sub::Throttle qw(throttle);
  
  my $load = 0.1;
  
  throttle($load, sub { ... });
  throttle($load, \&subref, @args);

DESCRIPTION

Throttles the load of perl function by calling sleep.

METHODS

throttle($load, $subref [, @subargs])

Calls sleep after executing $subref with given @subargs so that the ratio of execution time becomes equal to $load.

AUTHOR

Kazuho Oku <kazuhooku at gmail.com>

COPYRIGHT AND LICENSE

Copyright (C) 2008 by Cybozu Labs, Inc.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.