File: timeout_cb.t

package info (click to toggle)
libevent-perl 1.11-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 712 kB
  • ctags: 593
  • sloc: ansic: 3,034; perl: 1,128; makefile: 50
file content (30 lines) | stat: -rw-r--r-- 490 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# -*-perl-*-

use Test; plan tests => 6;
use Event qw(loop);

sub step1 {
    my ($e) = @_;
    ok $e->got, 't';
    $e->w->timeout_cb(undef);
}

sub step2 {
    my ($e) = @_;
    ok $e->got, 't';
    $e->w->cancel;
}

Event->io(timeout => .1, timeout_cb => \&step1, cb => \&step2);

sub method {
    step1($_[1]);
}

Event->io(timeout => .1, timeout_cb => ['main','method'],
	  cb => \&step2);

Event->io(timeout => .1, timeout_cb => [bless([],'main'),'method'],
	  cb => \&step2);

loop;