Hi --

I'm trying to use Event.pm to do some pretty basic event handling
(watching for incoming data on a named pipe, and eventually some timers)
but I keep having trouble with CPU usage.  Seems that once the loop
starts, my script uses all available cpu.  The script I'm using to test
with is below.  What am I doing wrong?

--Colin


#!/usr/local/bin/perl

use Event;


my $FIFO = "/tmp/fifo";

unless (-p $FIFO) {
        unlink $FIFO;
        system('mknod',$FIFO,'p');
}

open(FIFO, "<$FIFO") or die "can't read $FIFO: $!";

my $watcher = Event->io(
        cb      =>\&showMe,
        fd      =>\*FIFO,
        poll    =>'r');


my $ret =Event::loop();

sub showMe {
        while (<FIFO>) {
                chomp;
                print "got something: $_\n";
                if (/quit/) { &shutDown; }
        }
}

sub shutDown {
        Event::unloop();
        print "Ending loop! $ret \n";
        close FIFO;
        exit;
}









Reply via email to