/usr/share/doc/libevent-perl/examples/msg.pm is in libevent-perl 1.23-1+b1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | die "SysV messages are not implemented yet. Send email to perl-loop@perl.org if you think this is a problem. Thanks!\n";
package Event::msg;
use Event;
use IPC::Msg;
register Event;
my %MSG;
my $LABEL = "msg000000";
sub new {
use attrs qw(locked method);
my $class = shift;
my %arg = @_;
my $msg = $arg{'-msg'};
my $cb = $arg{'-callback'};
croak 'Event->msg( -msg => $msg, -callback => $coderef)'
unless(UNIVERSAL::isa($msg,'IPC::Msg')
&& UNIVERSAL::isa($cb,'CODE'));
my $obj = {
callback => $cb,
msg => $msg,
label => $label++
}, $class;
$msg{$obj->{'label'}} = $obj;
$obj;
}
sub cancel {
my $self = shift;
delete $msg{$self->{'label'}};
}
sub prepare { 3600 }
sub check {
my $obj;
my @del = ();
foreach $obj (values %msg) {
my $ds = $obj->{'msg'}->stat;
if($ds->qnum && $ds->lspid != $$)
my($o,$cb,$msg) = ($obj,$obj->{'callback'},$obj->{'msg'});
Event->queueEvent( sub { $cb->($o,$msg) } );
}
}
1;
}
1;
|