Your SlideShare is downloading. ×
YAPC::Brasil 2009, POE
YAPC::Brasil 2009, POE
YAPC::Brasil 2009, POE
YAPC::Brasil 2009, POE
YAPC::Brasil 2009, POE
YAPC::Brasil 2009, POE
YAPC::Brasil 2009, POE
YAPC::Brasil 2009, POE
YAPC::Brasil 2009, POE
YAPC::Brasil 2009, POE
YAPC::Brasil 2009, POE
YAPC::Brasil 2009, POE
YAPC::Brasil 2009, POE
YAPC::Brasil 2009, POE
YAPC::Brasil 2009, POE
YAPC::Brasil 2009, POE
YAPC::Brasil 2009, POE
YAPC::Brasil 2009, POE
YAPC::Brasil 2009, POE
YAPC::Brasil 2009, POE
YAPC::Brasil 2009, POE
YAPC::Brasil 2009, POE
YAPC::Brasil 2009, POE
YAPC::Brasil 2009, POE
YAPC::Brasil 2009, POE
YAPC::Brasil 2009, POE
YAPC::Brasil 2009, POE
YAPC::Brasil 2009, POE
YAPC::Brasil 2009, POE
YAPC::Brasil 2009, POE
YAPC::Brasil 2009, POE
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

YAPC::Brasil 2009, POE

502

Published on

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
502
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. POE Edgar Allan POE... POEtry ... Panel Of Experts ... Parallel Object Executor ... Parcel Out Execution ... Parenthetically Over- Engineered ... Parity Of Evil ... Part Of Elephant ... Particles Of Eternity ... Party On, Ebenezer ... Passed Out from Excitement ... Pathetically Over-Engineered ... Peace On Earth ... People Of Earth ... Perfect Orange Eater ... Perfectly Oblique Eggplant ... Periodically Orbits Earth ... Perl Obfuscation Engine ... Perl Object Environment ... Perl Objects for Enterprises ... Perl Objects for Events ... Perl On Extasy ... Perl Operating Environment ... Perl Operator Extravaganza ... Perl Over Easy ... Perl Over Ethernet ... Perl Overdrive Engine ... Perl, Objects and Events ... Perl: Objectively Excellent ... Perlmud Offers Expansions ... Perpetual Orgone Energy ... Persistent Object Environment ... Persnickity Oblong Erudition ... Perversely Oriented Entities ... Philanthropic Organization Enterprises ... Physician Order Entry ... Piece Of Eden ... Piece Of Eight ... Pigs, Owls, and Elephants ... Piles Of Eugh ... Pious Object Excelsior ... Piracy Over Ethernet ... Pissed Off Elephants ... Plain Old English ... Plastic Orbs Everywhere ... Platonic Object Engine ... Plenty Of Everything ... Plucky Object Engine ... Poe Oracle Environment ... Poe Organizes Everything ... Poe Over Earth ... Point Of Entry ... Polyolester ... Port of Embarkment ... Portal Of Evil ... Possibly Over-Engineered ... Post-Occupancy Evaluation ... Potatoes Of Eternity ... Potentially Omnipotent Entity ... Pow! Oof! Eek! ... Power Operating Environment ... Power Over Ethernet ... Practical Over Extraction ... Practically Overengineered Environment ... Preponderance of Evidence ... Preserve Our Essences ... Pretty Obelisk, Excavated ... Pretty Obfuscation Engine ... Pretty Obtuse Engine ... Pretty Odd Environment ... Price Of Entity ... Princess On Ecstasy ... Probable Obese Elephant ... Product Of Experts ... Products Of Eccentricity ... Prognosis: Over- Engineered ... Program Office Estimate ... Programming Over Easy ... Proliferation Of Events ... Prolifically Over-Eaten ... Purity Of Essence ... Purveyor Of Everything ... YAPC::Brasil::2009 Thiago Rondon
  • 2. FRAMEWORK
  • 3. EVENT DRIVEN
  • 4. MULTITASKING
  • 5. FORKING & THREADING ?
  • 6. AD-HOC EVENTS
  • 7. DISTRIBUTED PROGRAMMING ::IKC
  • 8. TESTED SYSTEM 1998-2000.........
  • 9. GROWING TOOLBOX
  • 10. Layer 3 POE::Component POE:: Layer 2 [Wheel,Filter,Driver] POE::Session Layer 1 POE::Kernel
  • 11. COMPONENT POE::Kernel Disparador de eventos, WHEEL POE::Loop::Select SESSION Singleton Post & yield KERNEL Timers
  • 12. COMPONENT POE::Session WHEEL Responde aos eventos $_[OBJECT] $_[SESSION] SESSION $_[HEAP] $_[STATE] KERNEL $_[SENDER] $_[ARG0..ARG9]
  • 13. COMPONENT POE::Wheel “Plugins” para a sessão. WHEEL Encapsular conjuntos de manipuladores de eventos. SESSION #Exemplo: POE::Wheel::Run #Executa um programa ou um conjunto de código em um subprocesso usando fork() e troca informações pelo stdin, stdout, stderr. KERNEL
  • 14. COMPONENT POE::Component 564 componentes no WHEEL CPAN até ontem. (30/Outubro/2009) SESSION POE::Component::IRC, POE::Component::Server::Radius POE::Component::Server::TCP POE::Component::Server::HTTP POE::Component::Github KERNEL POE::Component::Jabber (...)
  • 15. ESTUDO DE CASOS
  • 16. “Ping Múltiplo”
  • 17. use POE; use POE::Component::Client::Ping; my @addresses = qw(200.219.201.245 200.219.201.246 200.219.201.247); POE::Component::Client::Ping->spawn( Alias => 'pinger', Timeout => 5, SESSION ); POE::Session->create( COMPONENT inline_states => { _start => &client_start, pong => &client_got_pong, } );
  • 18. sub client_start { my ($kernel, $session) = @_[KERNEL, SESSION]; print "Starting to ping hosts.n"; foreach my $address (@addresses) { $kernel->post( pinger => ping => pong => $address); } }
  • 19. sub client_got_pong { my ($kernel, $session) = @_[KERNEL, SESSION]; my $request_packet = $_[ARG0]; my ($request_packetest_address, $request_timeout, $request_time) = @{$request_packet}; my $response_packet = $_[ARG1]; my ($response_address, $roundtrip_time, $reply_time) = @{$response_packet}; if (defined $response_address) { printf("Pinged %-15.15s - Response from %-15.15s in %6.3fsn", $request_address, $response_address, $roundtrip_time); } else { print "Time's up for responses from $request_address.n"; } }
  • 20. KERNEL $poe_kernel->run();
  • 21. IRC
  • 22. #!/usr/bin/perl use warnings; use strict; use POE; use POE::Component::IRC; my ($irc) = POE::Component::IRC->spawn(); POE::Session->create( inline_states => { _start => &bot_start, irc_001 => &on_connect, irc_public => &on_public, }, );
  • 23. #!/usr/bin/perl use warnings; COMPONENT use strict; use POE; use POE::Component::IRC; my ($irc) = POE::Component::IRC->spawn(); POE::Session->create( inline_states => { _start => &bot_start, irc_001 => &on_connect, irc_public => &on_public, }, );
  • 24. #!/usr/bin/perl use warnings; SESSION use strict; use POE; COMPONENT use POE::Component::IRC; my ($irc) = POE::Component::IRC->spawn(); POE::Session->create( inline_states => { _start => &bot_start, irc_001 => &on_connect, irc_public => &on_public, }, );
  • 25. COMPONENT sub bot_start { $irc->yield(register => "all"); $irc->yield( connect => { Nick => 'maluco_yapc', Username => 'maluco', Ircname => 'YAPC Brasil 2009', Server => 'irc.perl.org', Port => '6667', } ); }
  • 26. COMPONENT sub on_connect { $irc->yield(join => “#yapcbrasil”); }
  • 27. KERNEL COMPONENT sub on_public { my ($kernel, $who, $where, $msg) = @_[KERNEL, ARG0, ARG1, ARG2]; my $nick = (split /!/, $who)[0]; my $channel = $where->[0]; my $ts = scalar localtime; print " [$ts] <$nick:$channel> $msgn"; if (my ($response) = $msg =~ /^$nick (.+)/) { $irc->yield(privmsg => $channel, “estamos aqui.“); } }
  • 28. KERNEL $poe_kernel->run();
  • 29. Rocco Caputo
  • 30. http://poe.perl.org
  • 31. Obrigado! Thiago Rondon thiago@aware.com.br http://www.aware.com.br/

×