Remove redundant bulking

This commit is contained in:
Daniil Gentili 2024-06-21 19:32:16 +02:00
parent 3766db0223
commit 7ce856e9c4

View File

@ -44,37 +44,6 @@ class ApiController extends AbstractApiController
return $this->callApiCommon($madelineProto);
}
//GROUP REQUESTS IN BULKS
static $futures = [];
$futures[] = $future = async($this->callApiCommon(...), $madelineProto);
delay($this->waitNextTick());
if ($futures) {
awaitAll($futures);
Logger::getInstance()->notice("Executed bulk requests:" . count($futures));
$futures = [];
return $this->callApiCommon($madelineProto);
}
return $future->await();
}
/**
* Sync threads execution via time ticks
* Need to enable madelineProto futures bulk execution
* @param float $tick interval of execution in seconds.
*/
protected function waitNextTick(float $tick = 0.5): float {
$tickMs = $tick * 1000;
$now = (int)(microtime(true) * 1000);
$currentTick = intdiv((int)(microtime(true) * 1000), $tickMs);
$nextTick = ($currentTick + 1);
$nextTickTime = $nextTick * $tickMs;
$wait = round(($nextTickTime - $now)/1000, 3);
Logger::getInstance()->notice("Waiting $wait seconds before tick");
return $wait;
}
}