/** * Wait for the lock * @param float $timeout The timeout to wait before stop trying * @return bool False on error */ public static function waitForLock($timeout = 60.0) { $start = microtime(true); while (Atomic::isLocked() && microtime(true) - $start < $timeout) { usleep(500000); } if (microtime(true) - $start >= $timeout) { return false; } return Atomic::lock(); }