POE::Component::Generic

POE::Component::Generic is a POE component that provides non-blocking access to a blocking object.
Download

POE::Component::Generic Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • David Davis and Teknikill Software
  • Publisher web site:
  • http://search.cpan.org/~gwyn/POE-Component-Generic-0.1007/lib/POE/Component/Generic.pm

POE::Component::Generic Tags


POE::Component::Generic Description

POE::Component::Generic is a POE component that provides non-blocking access to a blocking object. POE::Component::Generic is a POE component that provides non-blocking access to a blocking object.SYNOPSIS use POE::Component::Generic; my $telnet = POE::Component::Generic->spawn( # required; main object is of this class package => 'Net::Telnet', # optional; Options passed to Net::Telnet->new() object_options => , # optional; You can use $poco->session_id() instead alias => 'telnet', # optional; 1 to turn on debugging debug => 1, # optional; 1 to see the child's STDERR verbose => 1, # optional; Options passed to the internal session options => { trace => 1 }, # optional; describe package signatures packages => { 'Net::Telnet' => { # Methods that require coderefs, and keep them after they # return. # The first arg is converted to a coderef postbacks => { option_callback=>0 } }, 'Other::Package' => { # only these methods are exposed methods => , # Methods that require coderefs, but don't keep them # after they return callbacks => } } ); # Start your POE session, then... $telnet->open( { event => 'result' }, "rainmaker.wunderground.com"); # result state sub result { my ($kernel, $ref, $result) = @_; if( $ref->{error} ) { die join(' ', @{ $ref->{error} ) . "n"; } print "connected: $resultn"; } # Setup a postback $telnet->option_callback( {}, "option_back" ); # option_back state sub option_back { my( $obj, $option, $is_remote, $is_enabled, $was_enabled, $buf_position) = @_; # See L for a discussion of the above. # NOTE: Callbacks and postbacks can't currently receive objects. } # Use a callback # Pretend that $other was created as a proxy to an Other::Package object $other->two( {}, sub { warn "I was called..." } ); my $code = $session->postback( "my_state" ); $other->two( {}, $code );POE::Component::Generic is a POE component that provides a non-blocking wrapper around any object. It works by forking a child process with POE::Wheel::Run and creating the object in the child process. Method calls are then serialised and sent via STDIN to the child to be handled. Return values are posted back to your session via STDOUT. This means that all method arguments and return values must survive serialisation. If you need to pass coderefs, use "callbacks", "postbacks" or "factories".Method calls are wrapped in eval in the child process so that errors may be propagated back to your session. See "OUTPUT".Output to STDERR in the child, that is from your object, is shown only if debug or verbose is set.STDOUT in the child, that is from your object, is redirected to STDERR and will be shown in the same circomstances. Requirements: · Perl


POE::Component::Generic Related Software