Skip to content

Commit

Permalink
"When three people tell you you're sick, lie down." Matt Cashner,
Browse files Browse the repository at this point in the history
Artur Bergman, and Todd Caine told me the "POE::Kernel's run() method
was never called." warning was annoying.  I suggested not emitting the
warning if no sessions were created (so perl -c and some tests don't
carp).  That seemed ok with everyone, so this commit implements that
change.
  • Loading branch information
rcaputo committed Jul 31, 2002
1 parent 93b1602 commit d06a44f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/POE/Kernel.pm
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ sub KR_SIZE () { 13 } # XXX UNUSED ???
# This flag indicates that POE::Kernel's run() method was called.
# It's used to warn about forgetting $poe_kernel->run().

my $kr_run_was_called = 0;
sub KR_RUN_CALLED () { 0x01 } # $kernel->run() called
sub KR_RUN_SESSION () { 0x02 } # sessions created
my $kr_run_warning = 0;

#------------------------------------------------------------------------------
# Session structure.
Expand Down Expand Up @@ -1425,7 +1427,7 @@ sub run {
my $self = $poe_kernel;

# Flag that run() was called.
$kr_run_was_called++;
$kr_run_warning |= KR_RUN_CALLED;

{% substrate_main_loop %}

Expand All @@ -1442,7 +1444,9 @@ sub DESTROY {
# detection could be included here.

warn "POE::Kernel's run() method was never called.\n"
unless $kr_run_was_called;
if ( ($kr_run_warning & KR_RUN_SESSION) and not
($kr_run_warning & KR_RUN_CALLED)
);
}

#------------------------------------------------------------------------------
Expand Down Expand Up @@ -1569,6 +1573,9 @@ sub session_alloc {
if (exists $kr_sessions{$session});
}

# Register that a session was created.
$kr_run_warning |= KR_RUN_SESSION;

$self->_dispatch_event
( $session, $kr_active_session,
EN_START, ET_START, \@args,
Expand Down

0 comments on commit d06a44f

Please sign in to comment.