mainLogger = new MainLogger(tempnam(sys_get_temp_dir(), "pmlog"), false, "Main", new \DateTimeZone('UTC')); $this->pool = new AsyncPool(2, 1024, new \BaseClassLoader(), $this->mainLogger, new SleeperHandler()); } public function tearDown() : void{ $this->pool->shutdown(); $this->mainLogger->shutdownLogWriterThread(); } public function testTaskLeak() : void{ $start = microtime(true); $this->pool->submitTask(new LeakTestAsyncTask()); while(!LeakTestAsyncTask::$destroyed && microtime(true) < $start + 30){ usleep(50 * 1000); $this->pool->collectTasks(); } self::assertTrue(LeakTestAsyncTask::$destroyed, "Task was not destroyed after 30 seconds"); } public function testPublishProgressRace() : void{ $task = new PublishProgressRaceAsyncTask(); $this->pool->submitTask($task); while($this->pool->collectTasks()){ usleep(50 * 1000); } self::assertTrue(PublishProgressRaceAsyncTask::$success, "Progress was not reported before task completion"); } }