0 follower

Final Class Yiisoft\Queue\Cli\SimpleLoop

InheritanceYiisoft\Queue\Cli\SimpleLoop
ImplementsYiisoft\Queue\Cli\LoopInterface
Uses TraitsYiisoft\Queue\Cli\SoftLimitTrait

Protected Properties

Hide inherited properties

Property Type Description Defined By
$memorySoftLimit integer Yiisoft\Queue\Cli\SimpleLoop

Property Details

Hide inherited properties

$memorySoftLimit protected property
protected integer $memorySoftLimit 0

Method Details

Hide inherited methods

__construct() public method

public mixed __construct ( integer $memorySoftLimit 0 )
$memorySoftLimit integer

Soft RAM limit in bytes. The loop won't let you continue to execute the program if soft limit is reached. Zero means no limit.

                public function __construct(protected int $memorySoftLimit = 0)
{
}

            
canContinue() public method

public boolean canContinue ( )

                public function canContinue(): bool
{
    return !$this->memoryLimitReached();
}

            
getMemoryLimit() protected method

protected integer getMemoryLimit ( )

                protected function getMemoryLimit(): int
{
    return $this->memorySoftLimit;
}

            
memoryLimitReached() protected method
protected boolean memoryLimitReached ( )

                protected function memoryLimitReached(): bool
{
    $limit = $this->getMemoryLimit();
    if ($limit !== 0) {
        $usage = memory_get_usage(true);
        if ($usage >= $limit) {
            return true;
        }
    }
    return false;
}