| Store | Cart

win32 interval timers question

From: Stefan Parvu <spa...@kronometrix.org>
Thu, 14 May 2015 18:22:16 +0300
Hi,

Im porting some data recorders from UNIX/LInux to Win32 platform:
https://github.com/kronometrix/recording/blob/master/bin/freebsd/cpurec

Basically Im trying to replicate something like this in Win32, and I
have no idea how I can do that:


use Time::HiRes qw(time alarm setitimer ITIMER_REAL);
use POSIX qw(pause);


# how often do we trigger (seconds)?
my $first_interval = $interval;

# signal handler is empty
local $SIG{ALRM} = sub { };

# first value is the initial wait, second is the wait thereafter
setitimer( ITIMER_REAL, $first_interval, $interval );


while (1) {

    ### perform work here

    ### Check for end
    last if ++$loop == $loop_max;

    ### Interval
    pause;

}


This implementation allows me to sleep an exact number of seconds on
Linux or UNIX. I have tried Win32::Sleep on Windows but I end up
sleeping more than that. So questions:

1. How one can sleep 60secs no matter what for Win32 platforms ?

2. Is there anything like interval timers and signals for Win32 ? And
how we could do such things in Win32 ?

Many thanks,

-- 
Stefan Parvu <spa...@kronometrix.org>
_______________________________________________
Perl-Win32-Users mailing list
Perl...@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Recent Messages in this Thread
Stefan Parvu May 14, 2015 03:22 pm