File: rand_interval.t

package info (click to toggle)
libevent-perl 1.15-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 792 kB
  • sloc: ansic: 3,034; perl: 1,128; makefile: 2
file content (16 lines) | stat: -rw-r--r-- 323 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/usr/bin/perl -w
# contributed by jsalmon@gw.thesalmons.org

use Event qw(loop);
require Event::timer;

$w = Event->timer(interval => 1, parked=>1);
$w->cb(sub {
	   my $next = rand(10);
	   print(scalar localtime(Event::time()), ": waiting ",
		 $next, " sec\n");
	   $w->interval($next);
       });
$w->start;

loop();