Hello. I am writing a perl program that sleeps until I get a notification from through Postgres DBD then wakes up and does something. Here is how it works now:
my $sleeptime = 0.10; $dbh->do("LISTEN mysignal");
while () {
$listen = $dbh->func('pg_notifies'); if (ref($listen)) { do_some_sub_here(); } select(undef, undef, undef, $sleeptime); }
Is there a more efficient way to do this? Right now my program is waking up and evaluating if $listen is defined each time it wakes up. This does work quite well, when I look in top I see the program uses 0% CPU while sleeping. I would like to make my program as responsive as possible so I was wondering if there was some way to make this more efficient? Like some way to tell perl to sleep indefiantely unless $listen becomes defined.
Thank you. Johnny
_________________________________________________________________
MSNŽ Calendar keeps you organized and takes the effort out of scheduling get-togethers. http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines Start enjoying all the benefits of MSNŽ Premium right now and get the first two months FREE*.
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>