> If you have a (simple) testcase that demonstrates the > problem I'd be happy to take a look at it.
Here is a simple POE::Component:IKC implementation. You'll have to run both with different processes. Uncommenting the server's async call throws an exception on win32 with ActiveState Perl. Any ideas how to make POE really thread-safe?
Kind regards.
Michael.
For the sample code,CLIENT IMPLEMENTATION# ==================================================================== +========== # SERVER IMPLEMENTATION # exec: perl src.pl # ==================================================================== +========== #!/usr/bin/perl -w # ==================================================================== +========== use strict; use POE qw(Session); use POE::Component::IKC::Server; use POE::Component::IKC::Specifier; use threads; # ==================================================================== +========== my $port = '32032'; my $ip = '127.0.0.1'; my $name = 'ThreadTest'; my $alias = 'TT'; # === INTER KERNEL COMMUNICATION ===================================== +========== create_ikc_server( ip => $ip, port => $port, name => $name ); POE::Session -> new ( # --- general states --------------------------------------------- +------ _start => \&start, # session start # --- service requests ------------------------------------------- +------ 'call' => \&call, # ---------------------------------------------------------------- +------ ); $poe_kernel->run(); # === IKC STATES ===================================================== +========== sub start { my($kernel, $heap) = @_[KERNEL, HEAP]; print "State [start]\n"; $kernel -> alias_set( $alias ); $kernel -> call( 'IKC', 'publish', $alias, [ qw( call ) ] ); } # ==================================================================== +========== sub call { my($kernel, $heap, $param) = @_[KERNEL, HEAP, ARG0]; print "State [call]\n"; async { } -> detach; return [ ]; } # ==================================================================== +========== __END__
# ==================================================================== +========== # CLIENT IMPLEMENTATION # exec: perl cln.pl # ==================================================================== +========== #!/usr/bin/perl -w # ==================================================================== +========== use strict; use POE qw( Session ); use POE::Component::IKC::Client; use POE::Component::IKC::Responder; # ==================================================================== +========== my $ip = '127.0.0.1'; my $port = '32032'; my $myName = $$; # ==================================================================== +========== create_ikc_client( ip => $ip, port => $port, name => $myName, subscribe => [ "poe://ThreadTest/TT" ], ); POE::Session -> new ( _start => \&start, remoteSubscribe => \&remoteSubscribe, runTestDone => \&runTestDone, ); $poe_kernel -> run; # === IKC STATES ===================================================== +========== sub start { my ($self, $kernel, $heap) = @_[ OBJECT, KERNEL, HEAP ]; print "State [start]\n"; create_ikc_responder(); $kernel -> alias_set( 'test' ); $kernel -> post( 'IKC', 'publish', 'test', [ qw( runTestDone ) ] ); $kernel -> post( 'IKC', 'monitor', 'ThreadTest', { subscribe => 'remoteSubscribe', } ); } # ==================================================================== +========== sub remoteSubscribe { my ($kernel, $heap, $name, $real_name, $what) = @_[ KERNEL, HEAP, +ARG0, ARG1, ARG4 ]; print "State [remoteSubscribe]\n"; return unless $real_name eq 'ThreadTest'; $kernel -> alias_set( 'test' ); $kernel -> post( 'IKC', 'call', "poe://ThreadTest/TT/call", [ $kernel -> ID ], 'poe:runTestDone' ); } # ==================================================================== +========== sub runTestDone { my ($kernel, $heap, $rData, $session) = @_[ KERNEL, HEAP, ARG0, SE +SSION ]; print "State [runTestDone]\n"; $kernel -> call( 'IKC', 'retract', 'test' ); $kernel -> alias_remove( 'test' ); $kernel -> post( IKC => 'shutdown' ); $kernel -> yield( 'shutdown' ); } # ==================================================================== +========== __END__
In reply to Re^8: POE and Win32::Process control
by m-rau
in thread POE and Win32::Process control
by m-rau
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |