Deprecated: Assigning the return value of new by reference is deprecated in /home/bluestat/public_html/source/index.php on line 477
phalanx - Commitdiff - ViewGit - Blue Static

Fix a bug; need to use work_queue->Dequeue() rather than Pop().

Robert Sesek [2011-02-13 14:46]
Fix a bug; need to use work_queue->Dequeue() rather than Pop().

Now all existing TaskPump tests pass.
diff --git a/tasks/task_pump.php b/tasks/task_pump.php
index 7b6e76a..de25d4e 100644
--- a/tasks/task_pump.php
+++ b/tasks/task_pump.php
@@ -54,7 +54,7 @@ class TaskPump
     // came in.
     public function QueueTask(Task $task)
     {
-        $this->work_queue->Push($task);
+        $this->work_queue->Enqueue($task);
     }

     // Schedules the |$task| as priority work, which executes before queued
@@ -119,7 +119,7 @@ class TaskPump
             // Handle queued work once per loop iteration to ensure that
             // priority work gets serviced.
             if ($this->work_queue->Count() > 0) {
-                $this->_RunTask($this->work_queue->Pop());
+                $this->_RunTask($this->work_queue->Dequeue());
                 $did_work = TRUE;
             }

diff --git a/testing/tests/tasks/task_pump_test.php b/testing/tests/tasks/task_pump_test.php
index 2c4ec64..ff2ca59 100644
--- a/testing/tests/tasks/task_pump_test.php
+++ b/testing/tests/tasks/task_pump_test.php
@@ -236,8 +236,6 @@ class TaskPumpTest extends \PHPUnit_Framework_TestCase
         $this->pump->QueueTask($task1);
         $this->pump->QueueTask($task2);
         $this->pump->Loop();
-        print_r($this->pump->GetTaskHistory());
-        print_r($this->pump->GetAllTasks());
         $this->assertEquals(2, $this->pump->GetTaskHistory()->Count());
         $this->assertSame($task2, $this->pump->GetTaskHistory()->Top());
         $this->assertSame($task1, $this->pump->GetTaskHistory()->Bottom());