nothingmuch has asked for the wisdom of the Perl Monks concerning the following question:
Any suggestions?my $x = 10; # the number of iterations to do between each sync my $int = 10; # the desired interval between actions my $y = 0; # another iteration limit, for catching up foo: { my $time = time(); for (my $i = 0; $i <= $y; $i++){ # catch up with real time from th +e last loop action(); # perform the action } for (my $i = 0; $i < $x; $i++){ action(); sleep $int; } my $ntime = time(); $y = int ( ($ntime - $time - $x * $int) / $int ); # calculate how +many we missed, and round down redo foo; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Accurately timed reccuring events
by Jenda (Abbot) on Mar 22, 2003 at 17:46 UTC | |
by nothingmuch (Priest) on Mar 22, 2003 at 19:10 UTC | |
|
Re: Accurately timed reccuring events
by mojotoad (Monsignor) on Mar 22, 2003 at 19:28 UTC | |
by aquarium (Curate) on Mar 24, 2003 at 03:16 UTC | |
|
Re: Accurately timed reccuring events
by benn (Vicar) on Mar 22, 2003 at 17:34 UTC | |
by nothingmuch (Priest) on Mar 22, 2003 at 19:03 UTC | |
|
Re: Accurately timed reccuring events
by bart (Canon) on Mar 25, 2003 at 13:16 UTC |