Help-Site Computer Manuals
Software
Hardware
Programming
Networking
  Algorithms & Data Structures   Programming Languages   Revision Control
  Protocols
  Cameras   Computers   Displays   Keyboards & Mice   Motherboards   Networking   Printers & Scanners   Storage
  Windows   Linux & Unix   Mac

Time::AutoRes
use Time::HiRes or fall back to core code

Time::AutoRes - use Time::HiRes or fall back to core code


NAME

Time::AutoRes - use Time::HiRes or fall back to core code


SYNOPSIS


    use Time::AutoRes qw(sleep time alarm);

    sleep(1.5);

    $now = time;

    alarm($now + 2.5);


DESCRIPTION

Time::AutoRes provides access to most of the functions that may be imported from Time::HiRes (see list below). If Time::HiRes isn't available, Time::AutoRes silently falls back to core Perl functions; when this happens, it tries to emulate Time::HiRes by rounding non-integers up or down in such a way as to approximate the non-integer value on average over repeated calls.

For example, if you call usleep(3.4), and if Time::HiRes is not available, there's a 40% chance of sleeping for 4 seconds, and a 60% chance of sleeping for only 3 seconds. If you call usleep(3.4) repeatedly, the average delay will tend toward 3.4 seconds.


EXPORTABLE FUNCTIONS

sleep($interval_in_seconds)
Sleep the given number of sleeps. If the interval is not an integer, and Time::HiRes is not available, Time::AutoRes will randomize the delay as described above so that repeated calls with the same interval can be expected to sleep the specified interval on average.

usleep($interval_in_microseconds)
Seleep the given number of microseconds. There are one million microseconds in a second. Randomness is used when Time::HiRes is not available and a non-integer argument is given, in exactly the same way as for Time::AutoRes::sleep.

alarm($interval_in_seconds)
Arranges to have a SIGALRM delivered to this process after the specified number of seconds have elapsed. Randomness is used when appropriate, as for Time::AutoRes::sleep.

ualarm($interval_in_microseconds)
Same as alarm but in microseconds rather than seconds. Again, randomness is used when appropriate.

time()
Returns the number of non-leap seconds since the epoch.

This simply calls Time::HiRes::time if it's available, or CORE::Time if not.

Note: This is the only exported function that never uses randomness!


BUGS

gettimeofday(), tv_interval(), getitimer() and setitimer() aren't implemented.


AUTHOR

Paul Hofman (nkuitse AT cpan DOT org).


COPYRIGHT

Copyright 2004 Paul M. Hoffman.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

Programminig
Wy
Wy
yW
Wy
Programming
Wy
Wy
Wy
Wy