Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: IO::Select: select vs. can_read

by MarkM (Curate)
on May 05, 2003 at 13:35 UTC ( #255617=note: print w/ replies, xml ) Need Help??


in reply to IO::Select: select vs. can_read

In theory, can_read() is more efficient in cases where you have a large number of clients that remains mostly constant between calls to can_read(), since add() and remove() should be performing only bit operations, wheras IO::Select::select() re-creates the bit mask every time.

In practice, I wouldn't be able to guess which one is faster. Graham Barr (the author of IO::Select) does implement add() and remove() using bit operations, however, he has a lot of rather inefficient code between add(), remove() and the code that actually does the bit operations.

Personally, I make the bit fields myself. The code isn't that complicated, and I handle things that can_read() does not such EINTR. add() is implemented in terms of vec(...) = 1, etc.


Comment on Re: IO::Select: select vs. can_read

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://255617]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (10)
As of 2015-07-03 17:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (54 votes), past polls