改名
This commit is contained in:
@@ -42,6 +42,7 @@ class Crontab extends BaseObject
|
|||||||
|
|
||||||
|
|
||||||
private int $execute_number = 0;
|
private int $execute_number = 0;
|
||||||
|
private array|Closure|null $_max_execute_handler = null;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -197,7 +198,7 @@ class Crontab extends BaseObject
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws \Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
private function recover()
|
private function recover()
|
||||||
{
|
{
|
||||||
@@ -211,6 +212,15 @@ class Crontab extends BaseObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Closure|array $closure
|
||||||
|
*/
|
||||||
|
public function setMaxExecute(Closure|array $closure)
|
||||||
|
{
|
||||||
|
$this->_max_execute_handler = $closure;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
@@ -241,14 +251,21 @@ class Crontab extends BaseObject
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws \Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
private function after(): void
|
private function after(): void
|
||||||
{
|
{
|
||||||
|
if ($this->isLoop()) {
|
||||||
|
$this->recover();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($this->max_execute_number == -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if ($this->getExecuteNumber() < $this->getMaxExecuteNumber()) {
|
if ($this->getExecuteNumber() < $this->getMaxExecuteNumber()) {
|
||||||
$this->recover();
|
$this->recover();
|
||||||
} else if ($this->isLoop()) {
|
} else {
|
||||||
$this->recover();
|
call_user_func($this->_max_execute_handler, ...$this->params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,10 +24,7 @@ class CrontabProviders extends Providers
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Application $application
|
* @param Application $application
|
||||||
* @throws ReflectionException
|
|
||||||
* @throws ComponentException
|
|
||||||
* @throws ConfigException
|
* @throws ConfigException
|
||||||
* @throws NotFindClassException
|
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function onImport(Application $application)
|
public function onImport(Application $application)
|
||||||
|
|||||||
Reference in New Issue
Block a user