The inline states should be looked upon as keywords pointing to a
subroutine. So you shouldn't have a subroutine named create_subscription.
It should be "sub cr_sub". Hope that helps.

-- 
Rohan


On Mon, Aug 13, 2012 at 6:26 PM, Gokul Prasad <nhgokulpra...@gmail.com>wrote:

> Hi,
>
> When am running this poe program, instead of going to cr_sub function,
> it directly goes to handle_task_result function, anything wrong?
>
>
>
> POE::Session->create(
>   inline_states => {
>     _start      => \&start_tasks,
>     create_subscription => \&cr_sub,
>     next_task   => \&start_tasks,
>     task_result => \&handle_task_result,
>     task_done   => \&handle_task_done,
>     task_debug  => \&handle_task_debug,
>     sig_child   => \&sig_child,
>   }
> );
>
> sub start_tasks {
>   my ($kernel, $heap) = @_[KERNEL, HEAP];
>   while (keys(%{$heap->{task}}) < MAX_CONCURRENT_TASKS) {
>     my $next_task = shift @events;
>     last unless defined $next_task;
>     print "Starting task for $next_task...\n";
>     my $task = POE::Wheel::Run->new(
>       Program      => sub {cr_sub($next_task)},
>       StdoutEvent  => "task_result",
>       CloseEvent   => "task_done",
>     );
>     $heap->{task}->{$task->ID} = $task;
>     $kernel->sig_child($task->PID, "sig_child");
>   }
> }
>
> sub create_subscription{
> my ($kernel, $heap) = @_[KERNEL, HEAP];
> .
> .
> .
>
> some heavy stuff here!!!!!!
> }
>
> sub handle_task_result { ####to call poller status method
>         my ($heap,$kernel) = @_[HEAP,KERNEL] ;
>        # my $pollquerystring = $_[ARG0]; ##lets use the heap hash
>        # my $plus_time = $_[ARG1];
>        if(!defined $heap->{RESULT}->{recordkey}){
>        while($end_time >= time){
>       #    print STDERR "I think c_sub box have some
> issues".time."+++++++ $heap->{RESULT}->{event} and
> $_[HEAP]->{next_alarm_time}++++\n";
> #                 $_[KERNEL]->delay(create_subscription => 30,
> $heap->{RESULT}->{event});
>                 $_[HEAP]->{next_alarm_time} = int(time()) + 30;
>               $_[KERNEL]->alarm(create_subscription =>
> $_[HEAP]->{next_alarm_time}, $heap->{RESULT}->{event});
>
>           $heap->{RESULT}->{cr_sub_error_counter}++;
>           }
>        }else{
>         $_[KERNEL]->delay(g_p_status => $heap->{RESULT}->{p_time});
> ### lets use the heap hash,$pollquerystring);
>         }
>
> }
>

Reply via email to