RE: Event examples || documentation

[email protected] ("Pavlovich, Matthew")
Newsgroups perl.loop
Message-ID <E78D8A9D6762D411B5440008C791D4AA01195127@dfwex03.allegiancetelecom.com>
	>use POSIX ":sys_wait_h";
	>Event->signal(signal => 'CHLD', cb => sub {
	>		  my ($e) = @_;
	>		  # warn "CHLD ".$e->hits;
	>		  for (my $h=0; $h < $e->hits; $h++) {
	>		      my $died = waitpid(-1,&WNOHANG);
	>                      # process it
	>		  }
	>	      });

	From the pod:

	hits=>$int
	  A watcher increments 'hits' every time it registers an event.
Signals in
	  quick succession can be clumped into a single event.

	What happens if two sigs come in at the same time?  Will all signals
be
	handled by the cb accordingly?

	Also, does signal handling using Event.pm suffer from the same
problems
	in perl where a signal handler that does something that malloc()'s?
ie print().

> > $w=Event->io(fd=>\$server, poll=>'r' , cb=\&handle_client)
> > loop;
> > 
> > $sig_watch=Event->signal(signal=>'chld', async=>1, cb=\&chld_mangler)
> 
	>Why async=>1?

	I dunno .. sounded good ? :)

	>Only loop() once.  ;-)

	Ok. I have a better understanding now.  loop until unloop() (which
needs to be 
	in a cb)  So I can create many event watchers, and once I loop(),
they all kick off.    

> > Am I heading in the right direction?
> 
	>Yes.  :-)

	Cool.  :)

	Thanks,
	Matt Pavlovich 
	Allegiance Telecom, Inc.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.