Network Programming With Anyevent

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    1 Favorite & 1 Event

    Network Programming With Anyevent - Presentation Transcript

    1. Network Programming with AnyEvent PtPW’08 - {mailto,xmpp}:melo@simplicidade.org
    2. Contenders • POE • Event • Danga::Socket • AnyEvent
    3. Overhead 10k servers, 20k sockets, 1% active 15,000 11,250 7,500 3,750 0 create request EV Perl Event Glib POE
    4. Overhead 10k servers, 20k sockets 300 225 150 75 0 create request EV Perl Event
    5. Overhead 8 servers, 16 sockets 300 225 150 75 0 create request EV Perl Event Glib POE
    6. Overhead 8 servers, 16 sockets 90.0 67.5 45.0 22.5 0 create request EV Perl Event Glib
    7. AnyEvent • framework for event driven programming • thin layer above several event loops • EV, Event, Gtk, Tk, POE • deals with IO handles (incl. unix domain sockets), timers, signals, processes • thousands of sockets with proper event loop (EV)
    8. Watchers and Condvars • AnyEvent has two basic concepts • Watchers • Condvars • Watchers wait for externals events: socket input, timer expiration, child process exits • Condvars are a synchronization primitive
    9. IO Watchers • Covers file handles, sockets, unix domain sockets • Deals with buffered reads and writes • Can also deal with “reading lines” or “block of bytes”: callback only when we have everything
    10. Timers • Execute callback sometime in the future • Single shot timers only • Common uses: timeouts
    11. Condvars • Provide syncronization inside your program • A simple broadcast service • Multiple interested parties • Anybody can trigger it • All the interested parties will be notified
    12. Read a line $| = 1; print \"enter your name> \"; my $name = <STDIN>;
    13. Read a line, take II use AnyEvent; $| = 1; print \"enter your name> \"; my $name; my $wait_for_input = AnyEvent->io ( fh => \\*STDIN, poll => \"r\", cb => sub { $name = <STDIN>; } );
    14. Demo • A simple broadcast server • Multiple clients • Broadcasts lines sent by one client to all the others • Code http://github.com/melo/presentations/
    15. Thanks!

    + Pedro MeloPedro Melo, 2 years ago

    custom

    1630 views, 1 favs, 0 embeds more stats

    A quick and dirty presentation about network progra more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 1630
      • 1630 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 1
    • Downloads 46
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories