- SEE ALSO
- COPYRIGHT AND LICENSE
POSIX::RT::Clock - POSIX real-time clocks
use POSIX::RT::Timer; my $timer = POSIX::RT::Clock->new('monotonic'); $timer->sleep(1);
POSIX::RT::Clock offers access to various clocks, both portable and OS dependent.
Create a new clock. The
$types supported are documented in
Get a list of all supported clocks. These will be returned by their names, not as objects. Possible values include (but may not be limited to):
The same clock as
timeand Time::HiRes use. It is the only timer guaranteed to always available and is therefor the default.
A non-settable clock guaranteed to be monotonic. This is defined in POSIX and supported on most operating systems.
A clock that measures (user and system) CPU time consumed by (all of the threads in) the calling process. This is supported on many operating systems.
A clock that measures (user and system) CPU time consumed by the calling thread. This is Linux specific.
A clock that measures the uptime of the system. This is FreeBSD specific.
A clock that counts time the process spent in userspace. This is supported only in FreeBSD, NetBSD and Solaris.
get_cpuclock($id = 0)
Get the cpu-time clock for
$idis an integer, it's interpreted as a PID and a per process clock is created, with zero having the special meaning of the current process (this is the same as the
threadobject, a per thread clock is created. This call is currently not supported on many operating systems.
Get the time of this clock.
Set the time of this clock. Note that this may not make sense on clocks other than
realtimeand will require sysadmin permissions.
Get the resolution of this clock.
sleep($time, $abstime = 0)
$timeseconds on this clock. Note that it is never restarted after interruption by a signal handler. It returns the remaining time. $time and the return value are relative time unless
$abstimeis true. This function may not be available on some operating systems.
sleep_deeply($time, $abstime = 0)
$timeseconds on this clock. Unlike
sleep, it will retry on interruption until the time has passed. This function may not be available on some operating systems.
Create a timer based on this clock. All arguments except
clockas the same as in
This returns the raw handle to the clock.
A low-level interface to POSIX clocks is also provided by:
Leon Timmermans <email@example.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2010 by Leon Timmermans.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.