develooper Front page | perl.cvs.p5ee | Postings from February 2013

[svn:p5ee] r15572 - p5ee/trunk/App-Context/lib/App/Context/POE

From:
spadkins
Date:
February 11, 2013 22:07
Subject:
[svn:p5ee] r15572 - p5ee/trunk/App-Context/lib/App/Context/POE
Message ID:
20130211220723.7FF6E184BA3@xx12.develooper.com
Author: spadkins
Date: Mon Feb 11 14:07:20 2013
New Revision: 15572

Modified:
   p5ee/trunk/App-Context/lib/App/Context/POE/Server.pm

Log:
In abort_async_event() mark an event as aborted.  Have dispatch_pending_async_events() check for aborted events and remove from the pending_async_events array.



Modified: p5ee/trunk/App-Context/lib/App/Context/POE/Server.pm
==============================================================================
--- p5ee/trunk/App-Context/lib/App/Context/POE/Server.pm	(original)
+++ p5ee/trunk/App-Context/lib/App/Context/POE/Server.pm	Mon Feb 11 14:07:20 2013
@@ -526,29 +526,35 @@
     while ($i <= $max_i && $events_occurred < $max_events) {
         $async_event = $pending_async_events->[$i];
         $event = $async_event->[0];
-        if ($event->{destination}) {
-            $self->send_async_event_now(@$async_event);
-            $events_occurred ++;
+
+        if ($event->{aborted}) {
             splice(@$pending_async_events, $i, 1);  # remove $pending_async_events->[$i]
             $max_i--;
-        }
-        elsif ($event_capacity_exists) {
-            $assigned = $self->assign_event_destination($event);
-            if ($assigned) {
+        } else {
+            if ($event->{destination}) {
                 $self->send_async_event_now(@$async_event);
                 $events_occurred ++;
-                # keep $i the same
                 splice(@$pending_async_events, $i, 1);  # remove $pending_async_events->[$i]
                 $max_i--;
             }
-            else {   # [undef] no servers are eligible for assignment
-                $event_capacity_exists = 0;   # there's no sense looking at the other pending async events
+            elsif ($event_capacity_exists) {
+                $assigned = $self->assign_event_destination($event);
+                if ($assigned) {
+                    $self->send_async_event_now(@$async_event);
+                    $events_occurred ++;
+                    # keep $i the same
+                    splice(@$pending_async_events, $i, 1);  # remove $pending_async_events->[$i]
+                    $max_i--;
+                }
+                else {   # [undef] no servers are eligible for assignment
+                    $event_capacity_exists = 0;   # there's no sense looking at the other pending async events
+                    $i++;   # look at the next one
+                }
+            }
+            else {      # [0] this async_event is not eligible to run
                 $i++;   # look at the next one
             }
         }
-        else {      # [0] this async_event is not eligible to run
-            $i++;   # look at the next one
-        }
     }
 
     $self->log({level=>3},"dispatch_pending_async_events exit: events_occurred=[$events_occurred] time=[" . sprintf("%.4f", tv_interval($t0, [gettimeofday])) . "]\n") if $self->{poe_trace};
@@ -774,7 +780,7 @@
     for (my $i = 0; $i <= $#$pending_async_events; $i++) {
         $async_event = $pending_async_events->[$i];
         if ($async_event->[0]{event_token} eq $event_token) {
-            splice(@$pending_async_events, $i, 1);
+            $async_event->[0]{aborted} = 1;
             $aborted = 1;
             last;
         }
@@ -1391,3 +1397,4 @@
 
 1;
 
+



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About