POE
Stefano Rodighiero
  OpenExp 2006
Perl
Object
Environment
       POE - A Perl Object Environment
?
    POE - A Perl Object Environment
Framework

     POE - A Perl Object Environment
Event
driven
    POE - A Perl Object Environment
Multitasking
Cooperativo
       POE - A Perl Object Environment
Single
thread
   POE - A Perl Object Environment
Networking

      POE - A Perl Object Environment
System
administration
        POE - A Perl Object Environment
GUI
  POE - A Perl Object Environment
POE - A Perl Object Environment
Component


  Wheel

            “Architettura”
 Session


 Kernel




                POE - A Perl Object Environment
Component


  Wheel
            Dispatch di eventi
 Session


 Kernel




               POE - A Perl Object Environment
Component


  Wheel
            Risponde agli eventi
 Session


 Kernel




                POE - A Perl Object Environment
Component

            “Plugin” per sessioni,
             incapsula insiemi di
  Wheel
               gestori di eventi
 ...
Component


  Wheel            POE::Component::IRC
               POE::Component::Server::TCP
            POE::Component::...
POE - A Perl Object Environment
Un programma tipico

• Istanzia una o più sessioni
 • Esplicitamente, eventualmente usando
    delle Wheel
 • Implicitamen...
sub POE::Kernel::TRACE_EVENTS() { 1 }




                       POE - A Perl Object Environment
use POE;

     POE - A Perl Object Environment
for ( 1 .. 3 ) {
  POE::Session -> create(
    inline_states => {
      _start => sub { print quot;Start!nquot; },
      _...
POE::Kernel->run();



            POE - A Perl Object Environment
_start

Session



             Kernel




          POE - A Perl Object Environment
_start

    Session

_start =>
  sub {
    print quot;Start!nquot;
                          Kernel
  }




              ...
Passaggio di messaggi

            Accoda un evento, da inoltrare
  post()       alla session specificata

            Acco...
Passaggio di messaggi

post()/yield()




                 POE - A Perl Object Environment
Passaggio di messaggi



call()




             POE - A Perl Object Environment
Comunicazione
 tra sessioni

        POE - A Perl Object Environment
# Sessione Babbo Natale
POE::Session->create(
   inline_states => {
     _start => sub {
       print quot;Oh oh oh!nquot;...
# Sessione Babbo Natale
POE::Session->create(
   inline_states => {
     _start => sub {
       print quot;Oh oh oh!nquot;...
# Sessione Babbo Natale
POE::Session->create(
   inline_states => {
     _start => sub {
       print quot;Oh oh oh!nquot;...
# Sessione Babbo Natale
POE::Session->create(
   inline_states => {
     _start => sub {
       print quot;Oh oh oh!nquot;...
# Sessione bimbo
POE::Session->create(
   inline_states => {
     _start => sub {
       $poe_kernel->alias_set( quot;Paol...
# Sessione bimbo
POE::Session->create(
   inline_states => {
     _start => sub {
       $poe_kernel->alias_set( quot;Paol...
Babbo Natale       _start




                                Kernel
Paolino
                         _start




         ...
Babbo Natale




                               Kernel
Paolino



      post( quot;Santaquot;, quot;letteraquot; )


     ...
lettera
          Babbo Natale




                               Kernel
Paolino




                         POE - A Perl...
lettera
           Babbo Natale
lettera




                                 Kernel
 Paolino



          post( quot;Santa...
POE - A Perl Object Environment
Wheel
   POE - A Perl Object Environment
Insiemi di
gestori di
  eventi
       POE - A Perl Object Environment
POE::
 Wheel::
FollowTail
      POE - A Perl Object Environment
use POE qw(
POE
POE
POE
POE
POE
POE
POE
POE
POE
POE
POE
POE
POE
POE
POE
POE
POE
POE
POE
POE
POE
POE
POE
POE
POE
POE
POE
POE
POE
POE
POE
POE
POE
POE
POE
POE
Upcoming SlideShare
Loading in …5
×

POE

3,169 views

Published on

An introduction to POE, the "Perl Object Environment", a framework for event driven state machines

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

No Downloads
Views
Total views
3,169
On SlideShare
0
From Embeds
0
Number of Embeds
61
Actions
Shares
0
Downloads
47
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

POE

  1. 1. POE Stefano Rodighiero OpenExp 2006
  2. 2. Perl Object Environment POE - A Perl Object Environment
  3. 3. ? POE - A Perl Object Environment
  4. 4. Framework POE - A Perl Object Environment
  5. 5. Event driven POE - A Perl Object Environment
  6. 6. Multitasking Cooperativo POE - A Perl Object Environment
  7. 7. Single thread POE - A Perl Object Environment
  8. 8. Networking POE - A Perl Object Environment
  9. 9. System administration POE - A Perl Object Environment
  10. 10. GUI POE - A Perl Object Environment
  11. 11. POE - A Perl Object Environment
  12. 12. Component Wheel “Architettura” Session Kernel POE - A Perl Object Environment
  13. 13. Component Wheel Dispatch di eventi Session Kernel POE - A Perl Object Environment
  14. 14. Component Wheel Risponde agli eventi Session Kernel POE - A Perl Object Environment
  15. 15. Component “Plugin” per sessioni, incapsula insiemi di Wheel gestori di eventi Session POE::Wheel::FollowTail POE::Wheel::Run Kernel POE - A Perl Object Environment
  16. 16. Component Wheel POE::Component::IRC POE::Component::Server::TCP POE::Component::Server::SimpleHTTP …CPAN… Session Kernel POE - A Perl Object Environment
  17. 17. POE - A Perl Object Environment
  18. 18. Un programma tipico • Istanzia una o più sessioni • Esplicitamente, eventualmente usando delle Wheel • Implicitamente, con Componenti già pronti • POE::Kernel->run() POE - A Perl Object Environment
  19. 19. sub POE::Kernel::TRACE_EVENTS() { 1 } POE - A Perl Object Environment
  20. 20. use POE; POE - A Perl Object Environment
  21. 21. for ( 1 .. 3 ) { POE::Session -> create( inline_states => { _start => sub { print quot;Start!nquot; }, _stop => sub { print quot;Stop!nquot; } } ); } POE - A Perl Object Environment
  22. 22. POE::Kernel->run(); POE - A Perl Object Environment
  23. 23. _start Session Kernel POE - A Perl Object Environment
  24. 24. _start Session _start => sub { print quot;Start!nquot; Kernel } POE - A Perl Object Environment
  25. 25. Passaggio di messaggi Accoda un evento, da inoltrare post() alla session specificata Accoda un evento, da inoltrare yield() alla session stessa Invoca - in maniera sincrona - un evento per una call() sessione specificata POE - A Perl Object Environment
  26. 26. Passaggio di messaggi post()/yield() POE - A Perl Object Environment
  27. 27. Passaggio di messaggi call() POE - A Perl Object Environment
  28. 28. Comunicazione tra sessioni POE - A Perl Object Environment
  29. 29. # Sessione Babbo Natale POE::Session->create( inline_states => { _start => sub { print quot;Oh oh oh!nquot;; $poe_kernel->alias_set( quot;Santaquot; ); }, lettera => sub { print quot;Lettera da quot; . $poe_kernel->alias_list( $_[SENDER] ); } } ); POE - A Perl Object Environment
  30. 30. # Sessione Babbo Natale POE::Session->create( inline_states => { _start => sub { print quot;Oh oh oh!nquot;; $poe_kernel->alias_set( quot;Santaquot; ); }, lettera => sub { print quot;Lettera da quot; . $poe_kernel->alias_list( $_[SENDER] ); } } ); POE - A Perl Object Environment
  31. 31. # Sessione Babbo Natale POE::Session->create( inline_states => { _start => sub { print quot;Oh oh oh!nquot;; $poe_kernel->alias_set( quot;Santaquot; ); }, lettera => sub { print quot;Lettera da quot; . $poe_kernel->alias_list( $_[SENDER] ); } } ); POE - A Perl Object Environment
  32. 32. # Sessione Babbo Natale POE::Session->create( inline_states => { _start => sub { print quot;Oh oh oh!nquot;; $poe_kernel->alias_set( quot;Santaquot; ); }, lettera => sub { print quot;Lettera da quot; . $poe_kernel->alias_list( $_[SENDER] ); } } ); POE - A Perl Object Environment
  33. 33. # Sessione bimbo POE::Session->create( inline_states => { _start => sub { $poe_kernel->alias_set( quot;Paolinoquot; ); $poe_kernel->post( quot;Santaquot; => 'lettera' ); }, } ); POE - A Perl Object Environment
  34. 34. # Sessione bimbo POE::Session->create( inline_states => { _start => sub { $poe_kernel->alias_set( quot;Paolinoquot; ); $poe_kernel->post( quot;Santaquot; => 'lettera' ); }, } ); POE - A Perl Object Environment
  35. 35. Babbo Natale _start Kernel Paolino _start POE - A Perl Object Environment
  36. 36. Babbo Natale Kernel Paolino post( quot;Santaquot;, quot;letteraquot; ) POE - A Perl Object Environment
  37. 37. lettera Babbo Natale Kernel Paolino POE - A Perl Object Environment
  38. 38. lettera Babbo Natale lettera Kernel Paolino post( quot;Santaquot;, quot;letteraquot; ) POE - A Perl Object Environment
  39. 39. POE - A Perl Object Environment
  40. 40. Wheel POE - A Perl Object Environment
  41. 41. Insiemi di gestori di eventi POE - A Perl Object Environment
  42. 42. POE:: Wheel:: FollowTail POE - A Perl Object Environment
  43. 43. use POE qw(

×