On 8/14/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
snip
> Its not really making sense to me why you are adding sleep to this.
> Cant I do this as fast as possible?
snip

I added sleep for two reasons, to show that it worked and to prevent
it from hogging the CPU.  With non-blocking IO you program can do what
is called a busy wait.  Basically the program is doing nothing but
waiting for there to be data to read, but it is still consuming %100
of the available CPU time.  If you want to see what a busy wait looks
like run this:

perl -e "1 while 1"

A one second sleep is common, but you can sleep for less than a second
with usleep from the Time::HiRes* module if this is too slow for your
purposes.

* http://search.cpan.org/~jhi/Time-HiRes-1.9707/HiRes.pm

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


Reply via email to