mirror of
https://github.com/danog/TelegramApiServer.git
synced 2024-11-29 20:09:05 +01:00
Remove redundant bulking
This commit is contained in:
parent
3766db0223
commit
7ce856e9c4
@ -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 $future->await();
|
||||
return $this->callApiCommon($madelineProto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user