GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
POE::Component::Generic::Object(3) User Contributed Perl Documentation POE::Component::Generic::Object(3)

POE::Component::Generic::Object - A POE component that provides non-blocking access to a blocking object.

    use POE::Component::Generic;

    my $generic = POE::Component::Generic->new( 
                    package=>'Builder', 
                    factories=>['build'] );

    $generic->build( {event=>'created_foo'}, 'foo' );

    # Note that this happens in a child process
    sub Builder::build {
        my( $package, $arg ) = @_;
        return bless { something=>$arg }, 'Other::Package';
    }

    # in the event "created_foo"
    # Note that this happens in the parent process
    sub create_foo {
        my( $resp, $foo ) = @_[ARG0, ARG1];
        die $resp->{error} if $resp->{error}

        # $foo is a proxy object to what Builder::build returned
        my $objID = $foo->object_id;        # Unique ID of the object

        $foo->vibble( {}, @args );          # call a method on the object foo
        $foo->yield( 'vibble', {}, @args ); # same as above   
        $foo->call( 'vibble', {}, @args );  # same as above   

        $generic->vibble( {obj=>$objID}, @args );   # same as above
    }

POE::Component::Generic::Object is a proxy object for objects that were created by factory methods in the child process

Returns a object ID for the object. This ID is unique to a given POE::Component::Generic component but might not be unique across POE::Component::Generic components.

Returns the session ID of the session that handles this object. Currently this corresponse to the parent POE::Component::Generic component, so it's not very useful. Eventually each proxy object will get its own session.

If you let the proxy object go out of scope, the object in the child will be destroyed.

THIS COULD BE SUPRISING.

Especially if you do something like:

    my( $resp, $obj ) = @_[ ARG0, ARG1 ];
    die $resp->{error} if $resp->{error};
    $obj = $obj->object_id;        # bang, no more sub-object.

However, it does allow you to control when the object will be reaped by the child process.

There are 3 ways of calling methods on the object.

All methods need a data hashref to specify the response event. This data hash is discussed in the "INPUT" section.

This method provides an alternative object based means of asynchronisly calling methods on the object. First argument is the method to call, second is the data hashref, following arguments are sent as arguments to the resultant method call.

  $poco->yield( open => { event => 'result' }, "localhost" );

This method provides an alternative object based means of synchronisly calling methods on the object. First argument is the method to call, second is the data hashref, following arguments are sent as arguments to the resultant method call.

  $poco->call( open => { event => 'result' }, "localhost" );

All methods of the object can be called, but the first param must be the data hashref as noted below in the "INPUT" section below.

For example:

    $poco->open( { event => 'opened' }, "localhost" );

Input works the same way as "INPUT" in POE::Component::Generic, except that the "obj" field defaults to the current object.

Input works the same way as "OUTPUT" in POE::Component::Generic.

Philip Gwyn <gwyn-at-cpan.org>

Based on work by David Davis <xantus@cpan.org>

POE

Please rate this module. <http://cpanratings.perl.org/rate/?distribution=POE-Component-Generic>

Probably. Report them here: <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=POE%3A%3AComponent%3A%3AGeneric>

Copyright 2006-2008, 2011 by Philip Gwyn;

Copyright 2005 by David Davis and Teknikill Software.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

2011-05-18 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.