Successfully reported this slideshow.

POE

3

Share

1 of 79
1 of 79

More Related Content

Related Books

Free with a 14 day trial from Scribd

See all

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(

×