On Tue, 2006-04-04 at 13:07 +1000, James Turnbull wrote:
> Mr. Shawn H. Corey wrote:
> > First question: are you running under M$ Windows or UNIX?
> >   
> Unix - Linux or BSD generally
> > Second question: does this periodic function relying on data of the main
> > process?
> >   
> Yes - it uses a hash defined in the mainline.
> 
> Regards
> 
> James Turnbull
> 

OK, this sounds like an ideal application of threads. I don't have much
experience with them, so I'll leave it to others to tell you how to use
them.

But if your Perl wasn't compiled with threads:

First, read `perldoc perlipc`.

I assume your mainline is waiting on input. Like:

  while( <> ){
    ...
  }

If you use alarm, then these waits will be interrupted by the alarm. So
you need a flag to indicate this:

  my $alarmed = 0;

  sub wakeup {
    $alarmed = 1;
    # the rest of wakeup
    alarm( 600 );
  }

  ...

  alarm( 600 );
  while( <> ){
    if( $alarmed ){
      $alarmed = 0;
      next;
    }
    ...
  }

 

-- 
__END__

Just my 0.00000002 million dollars worth,
   --- Shawn

"For the things we have to learn before we can do them, we learn by doing them."
  Aristotle

* Perl tutorials at http://perlmonks.org/?node=Tutorials
* A searchable perldoc is at http://perldoc.perl.org/



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to