File: queue_pending.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 (28 lines) | stat: -rw-r--r-- 792 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
#!/usr/bin/perl

use warnings;
use strict;

use Event qw(queue_pending);

# Zefram <zefram@fysh.org>
#
# If you already have a signal watcher, and then start a second one for
# the same signal, the counting continues unaffected by the start of
# the second watcher.  Both watchers will generate events for a signal
# received shortly before the second one was started.

Event->signal(signal => "USR1",
        cb => sub { print "handler 0 got hits=", $_[0]->hits, "\n"; });
kill "USR1" => 0;

# If "queue_pending();" is added to the program, immediately before
# the creation of the second watcher, then it produces different output.
#
# queue_pending();

Event->signal(signal => "USR1",
        cb => sub { print "handler 1 got hits=", $_[0]->hits, "\n"; });
kill "USR1" => 0;
Event::loop;