Heray-Was-Here
Server : Apache
System : Linux vps103298.mylogin.co 4.18.0-513.11.1.el8_9.x86_64 #1 SMP Wed Jan 17 02:00:40 EST 2024 x86_64
User : calvet ( 273824)
PHP Version : 7.4.33
Disable Function : NONE
Directory :  /proc/self/root/proc/thread-self/root/proc/self/root/usr/share/doc/perl-Event/demo/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //proc/self/root/proc/thread-self/root/proc/self/root/usr/share/doc/perl-Event/demo/msg.pm
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;


Hry