Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

How does AnyEvent work?

by Anonymous Monk
on Nov 17, 2022 at 21:43 UTC ( [id://11148231]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

If Perl is single threaded how does AnyEvent work? I mean does it spawn threads ,processes? Or is it like Nodejs event loop that does io so it doesn't spawn anything? And if that is so how does it handle CPU bound operations?

Replies are listed 'Best First'.
Re: How does AnyEvent work?
by Corion (Patriarch) on Nov 17, 2022 at 22:52 UTC

    AnyEvent is like NodeJS. Actually more appropriate, NodeJS is more like AnyEvent, as NodeJS is based on libuv, which I think is a fork of libev, the OG backend event loop for AnyEvent.

    Just as NodeJS, CPU bound operations block the rest, so you have to transfer them out of process.

      >so you have to transfer them out of process.
      I see.So how do you do that with Perl/AnyEvent?

        In general, you run a second process and send it commands to perform.

        See for example AnyEvent::Run, AnyEvent::Fork or any of the RPC modules.

Re: How does AnyEvent work?
by karlgoethebier (Abbot) on Nov 19, 2022 at 20:17 UTC

    Some sources:

    A look at UV could also be interesting. Quite surprising that no one at PM seems to use it. In any case, I have not found a thread in which the module is even mentioned.

    «The Crux of the Biscuit is the Apostrophe»

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11148231]
Approved by choroba
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (7)
As of 2024-04-18 07:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found