POE - Perl Object Environment
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

POE - Perl Object Environment

on

  • 663 views

 

Statistics

Views

Total Views
663
Views on SlideShare
660
Embed Views
3

Actions

Likes
2
Downloads
10
Comments
0

2 Embeds 3

http://www.linkedin.com 2
https://duckduckgo.com 1

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

CC Attribution-NonCommercial LicenseCC Attribution-NonCommercial License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

POE - Perl Object Environment Presentation Transcript

  • 1. POE Phil Whelan
  • 2. POE Perl OBJECT Environment
  • 3. POE Perl OBJECT Environment “POE is a framework for creating event-driven cooperative multitasking programs in Perl” --- Poe.Perl.Org
  • 4. POE Perl OBJECT Environment “POE is a framework for creating event-driven cooperative multitasking programs in Perl” --- Poe.Perl.Org
  • 5. Why POE ?
  • 6. Why POE ? Perl does this... A B C
  • 7. Why POE ? o two things Ho w to d at once??
  • 8. Why POE ? Mulitple processes do this... A B C A B C
  • 9. Why POE ? POE does this... A B C A B C
  • 10. Why POE ? POE does this like this... A B C A B C
  • 11. Why POE ? POE makes it easy to do this... HTTP A B C Server A B C SMTP A B C Server A B C
  • 12. Why POE ? one proc ess POE makes it easy to do this... only !! HTTP A B C Server A B C SMTP A B C Server A B C
  • 13. POE Hates
  • 14. POE Hates Blocking A B C
  • 15. POE Hates Blocking A B C $%!@ blocking!!!!
  • 16. POE Hates Blocking
  • 17. POE Hates Blocking causes queuing
  • 18. POE Hates Nobody likes queuing
  • 19. POE Hates
  • 20. Blocking One event stops, everything stops HTTP A B C Server A B C SMTP A B C Server A B C
  • 21. Non-Blocking Everything in a POE application should be non-blocking
  • 22. Non-Blocking
  • 23. Non-Blocking Reading from a socket?
  • 24. Non-Blocking Reading from a socket? - get POE to notify you when it’s ready
  • 25. Non-Blocking Reading from a socket? - get POE to notify you when it’s ready
  • 26. Non-Blocking Reading from a socket? - get POE to notify you when it’s ready Waiting for more data?
  • 27. Non-Blocking Reading from a socket? - get POE to notify you when it’s ready Waiting for more data? - get POE to notify you when more data is available to read
  • 28. Non-Blocking Reading from a socket? - get POE to notify you when it’s ready Waiting for more data? - get POE to notify you when more data is available to read
  • 29. Non-Blocking Reading from a socket? - get POE to notify you when it’s ready Waiting for more data? - get POE to notify you when more data is available to read SQL Request?
  • 30. Non-Blocking Reading from a socket? - get POE to notify you when it’s ready Waiting for more data? - get POE to notify you when more data is available to read SQL Request? - get POE to notify you when the response comes back
  • 31. Non-Blocking Reading from a socket? - get POE to notify you when it’s ready Waiting for more data? - get POE to notify you when more data is available to read SQL Request? - get POE to notify you when the response comes back
  • 32. Non-Blocking
  • 33. Non-Blocking Every system call should be broken into...
  • 34. Non-Blocking Every system call should be broken into... - Request
  • 35. Non-Blocking Every system call should be broken into... - Request & - Callback
  • 36. The POE Queue Your Code e nt nt ev eve event event POE Queue event event event event event
  • 37. The POE Queue Your Non-blocking Code e nt nt ev eve event event POE Queue event event event event event
  • 38. The POE Queue Your Code e nt nt ev eve event event POE Queue event event event event event
  • 39. The POE Queue system calls POE’s Your Blocking System Code Resources e nt nt ev eve event event POE Queue event event event event event
  • 40. The POE Queue system calls POE’s Your event event System Code ev ev nt en Resources nt ev en ve en t e ve t e t event event POE Queue event event event event event
  • 41. POE Components
  • 42. POE Components It’s like CPAN for POE!
  • 43. POE Components It’s like CPAN for POE! Example...
  • 44. POE Components It’s like CPAN for POE! Example... POE::Component::Client::DNS
  • 45. POE Components It’s like CPAN for POE! Example... POE::Component::Client::DNS What’s wrong with Net::DNS ??
  • 46. POE Components It’s like CPAN for POE! Example... POE::Component::Client::DNS What’s wrong with Net::DNS ??
  • 47. POE Components It’s like CPAN for POE! Example... POE::Component::Client::DNS Net::DNS request & response What’s happen inline. wrong with Net::DNS ??
  • 48. POE Components It’s like CPAN for POE! Example... POE::Component::Client::DNS Net::DNS request & response What’s happen inline. wrong with So it blocks. Net::DNS ??
  • 49. POE Components It’s like CPAN for POE! Example... POE::Component::Client::DNS Net::DNS request & response What’s happen inline. wrong with So it blocks. Net::DNS ??
  • 50. POE Components It’s like CPAN for POE! Example... POE::Component::Client::DNS Net::DNS request & response What’s happen inline. wrong with So it blocks. Net::DNS ?? Only one DNS request can occur at a time
  • 51. POE Components It’s like CPAN for POE! Example... POE::Component::Client::DNS
  • 52. POE Components It’s like CPAN for POE! Example... POE::Component::Client::DNS
  • 53. POE Components It’s like CPAN for POE! Example... POE::Component::Client::DNS Allows multiple DNS requests to occur simultaneously.
  • 54. Show us the code!!
  • 55. POE Sessions use POE; POE::Session->create( inline_states => { _start => sub { $_[KERNEL]->yield("next") }, next => sub { print "tick...n"; $_[KERNEL]->delay(next => 1); }, }, ); POE::Kernel->run(); exit;
  • 56. POE Sessions use POE; POE::Session->create( inline_states => { _start => sub { $_[KERNEL]->yield("next") }, next => sub { print "tick...n"; $_[KERNEL]->delay(next => 1); }, }, ); POE::Kernel->run(); exit;
  • 57. POE Sessions use POE; POE::Session->create( inline_states => { _start => sub { $_[KERNEL]->yield("next") }, next => sub { print "tick...n"; $_[KERNEL]->delay(next => 1); }, }, ); POE::Kernel->run(); exit;
  • 58. POE Sessions use POE; POE::Session->create( inline_states => { _start => sub { $_[KERNEL]->yield("next") }, next => sub { print "tick...n"; $_[KERNEL]->delay(next => 1); }, }, ); POE::Kernel->run(); exit;
  • 59. POE Sessions use POE; POE::Session->create( inline_states => { _start => sub { $_[KERNEL]->yield("next") }, next => sub { print "tick...n"; $_[KERNEL]->delay(next => 1); }, }, ); POE::Kernel->run(); exit;
  • 60. POE Sessions use POE; POE::Session->create( inline_states => { _start => sub { $_[KERNEL]->yield("next") }, next => sub { print "tick...n"; “ next” event POE $_[KERNEL]->delay(next => 1); }, Queue }, event ); event POE::Kernel->run(); event exit;
  • 61. POE Sessions use POE; POE::Session->create( inline_states => { _start => sub { $_[KERNEL]->yield("next") }, next => sub { print "tick...n"; “ next” event POE $_[KERNEL]->delay(next => 1); }, Queue }, event ); event POE::Kernel->run(); event exit;
  • 62. POE Sessions use POE; POE::Session->create( inline_states => { _start => sub { $_[KERNEL]->yield("next") }, next => sub { print "tick...n"; “ next” event POE $_[KERNEL]->delay(next => 1); }, Queue }, event ); event POE::Kernel->run(); “next” exit;
  • 63. POE Sessions use POE; POE::Session->create( inline_states => { _start => sub { $_[KERNEL]->yield("next") }, next => sub { print "tick...n"; “ next” event POE $_[KERNEL]->delay(next => 1); }, Queue }, event ); event POE::Kernel->run(); “next” exit;
  • 64. POE Sessions use POE; POE::Session->create( inline_states => { _start => sub { $_[KERNEL]->yield("next") }, next => sub { print "tick...n"; “ next” event POE $_[KERNEL]->delay(next => 1); }, Queue }, event ); event POE::Kernel->run(); “next” exit;
  • 65. POE Sessions use POE; POE::Session->create( inline_states => { _start => sub { $_[KERNEL]->yield("next") }, next => sub { print "tick...n"; “ next” event POE $_[KERNEL]->delay(next => 1); }, Queue }, event ); event POE::Kernel->run(); “ne exit; xt”
  • 66. POE Sessions use POE; POE::Session->create( inline_states => { _start => sub { $_[KERNEL]->yield("next") }, next => sub { print "tick...n"; $_[KERNEL]->delay(next => 1); }, }, ); POE::Kernel->run(); exit;
  • 67. POE Sessions use POE; POE::Session->create( inline_states => { _start => sub { $_[KERNEL]->yield("next") }, next => sub { print "tick...n"; $_[KERNEL]->delay(next => 1); }, }, ); POE::Kernel->run(); exit;
  • 68. POE Sessions use POE; POE::Session->create( inline_states => { _start => sub { $_[KERNEL]->yield("next") }, next => sub { print "tick...n"; $_[KERNEL]->delay(next => 1); }, }, ); POE::Kernel->run(); exit;
  • 69. POE Sessions tick... use POE; POE::Session->create( inline_states => { _start => sub { $_[KERNEL]->yield("next") }, next => sub { print "tick...n"; $_[KERNEL]->delay(next => 1); }, }, ); POE::Kernel->run(); exit;
  • 70. POE Sessions tick... use POE; POE::Session->create( inline_states => { _start => sub { $_[KERNEL]->yield("next") }, next => sub { print "tick...n"; $_[KERNEL]->delay(next => 1); }, }, “next” ); POE::Kernel->run(); exit;
  • 71. POE Sessions tick... tick... use POE; POE::Session->create( inline_states => { _start => sub { $_[KERNEL]->yield("next") }, next => sub { print "tick...n"; $_[KERNEL]->delay(next => 1); }, }, ); POE::Kernel->run(); exit;
  • 72. POE Sessions tick... tick... use POE; POE::Session->create( inline_states => { _start => sub { $_[KERNEL]->yield("next") }, next => sub { print "tick...n"; $_[KERNEL]->delay(next => 1); }, }, ); POE::Kernel->run(); exit;
  • 73. POE Sessions tick... tick... use POE; tick... POE::Session->create( inline_states => { _start => sub { $_[KERNEL]->yield("next") }, next => sub { print "tick...n"; $_[KERNEL]->delay(next => 1); }, }, ); POE::Kernel->run(); exit;
  • 74. POE Sessions tick... tick... use POE; tick... POE::Session->create( inline_states => { _start => sub { $_[KERNEL]->yield("next") }, next => sub { print "tick...n"; $_[KERNEL]->delay(next => 1); }, }, ); POE::Kernel->run(); exit;
  • 75. POE Sessions tick... tick... use POE; tick... tick... tick... POE::Session->create( inline_states => { tick... tick... _start => sub { $_[KERNEL]->yield("next") }, next => sub { tick... print "tick...n"; $_[KERNEL]->delay(next => 1); }, }, tick... ); POE::Kernel->run(); exit; tick.
  • 76. POE Sessions use POE; POE::Session->create( inline_states => { _start => sub { $_[KERNEL]->yield("next") }, next => sub { print "tick...n"; $_[KERNEL]->delay(next => 1); }, }, ); POE::Kernel->run(); exit;
  • 77. POE Sessions use POE; POE::Session->create( inline_states => { _start => sub { $_[KERNEL]->yield("next") }, next => sub { print "tick...n"; $_[KERNEL]->delay(next => 1); }, }, ); POE::Kernel->run(); exit;
  • 78. POE Scope
  • 79. POE Scope POE handles - Event context
  • 80. POE Scope POE handles - Event context - Event scope
  • 81. POE Scope POE handles - Event context - Event scope - Signal scope
  • 82. POE Scope Kernel (Root Session)
  • 83. POE Scope Kernel (Root Session) Session
  • 84. POE Scope Kernel (Root Session) Session 1 Session 2
  • 85. POE Scope Kernel (Root Session) Session 1 Session 2 Session 3
  • 86. POE Scope Kernel (Root Session) Session 1 Session 2 Session 3
  • 87. POE Scope Kernel (Root Session) Session 1 Session 2 Session 3 Component
  • 88. POE Scope Kernel (Root Session) Session 1 Session 2 Session 3 HTTP Server Component Component DBI Component
  • 89. POE Scope Kernel (Root Session) “e ve Session 1 nt”Session 2 nt “eve ” Session 3 HTTP Server Component Component DBI Component “event”
  • 90. POE Scope CALLING Kernel (Root Session) Session 1 Session 2 ( 2 , “event”)
  • 91. POE Scope CALLING Kernel (Root Session) Session 1 Session 2 ($session2 , “event”)
  • 92. POE Scope CALLING Kernel (Root Session) Session 1 Session 2 ( “Bond” , “event”) The name’s “Bond”
  • 93. POE Scope
  • 94. POE Scope POE Kernel Session
  • 95. POE Scope Perl process POE Kernel Session
  • 96. POE Scope Perl process POE Kernel Session POE::Wheel::Run
  • 97. POE Scope Perl process Perl process POE Kernel POE Kernel Session Session POE::Wheel::Run FORK
  • 98. POE Scope Perl process Perl process POE Kernel POE Kernel Session “event” Session POE::Wheel::Run “event” IO Wheel
  • 99. POE Scope Perl process Logging POE Kernel Session DBI DBI DBI
  • 100. POE Scope 12.40.45.26 POE::Component::IKC::Server “event” 22.1.122.6 POE::Component::IKC::Client
  • 101. Conclusion
  • 102. Conclusion - Great for doing many things concurrently, even if they are unrelated
  • 103. Conclusion - Great for doing many things concurrently, even if they are unrelated - Good management of scope
  • 104. Conclusion - Great for doing many things concurrently, even if they are unrelated - Good management of scope - Non-blocking nature makes it relatively high performance
  • 105. Conclusion - Great for doing many things concurrently, even if they are unrelated - Good management of scope - Non-blocking nature makes it relatively high performance - Requires non-blocking POE Modules, which limits CPAN usage