File: rand_interval.t

package info (click to toggle)
libevent-perl 1.28-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 776 kB
  • sloc: ansic: 3,035; perl: 1,122; makefile: 8
file content (16 lines) | stat: -rw-r--r-- 316 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!./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();