Parse updates

This commit is contained in:
Daniil Gentili 2019-06-05 21:41:42 +02:00
parent b59e62a725
commit c71dd59f87
2 changed files with 8 additions and 5 deletions

View File

@ -141,7 +141,6 @@ If your code still relies on the **old synchronous behaviour**, __don't worry__,
However, old synchronous behaviour is deprecated, and I **highly recommend** you switch to async, due to the **huge performance** and **parallelism benefits**.
***
To implement async, I wrote loads of new async APIs in MadelineProto, as you may have seen above.
I used the **awesome** [amphp](https://amphp.org) async framework as base, on which to build the new MadelineProto APIs.
I heavily modified amphp coroutines and wrapped [all of the AMPHP event loop methods](https://docs.madelineproto.xyz/docs/ASYNC.html#madelineproto-and-amphp-async-apis) to add native support for yielding generators.
@ -393,4 +392,7 @@ In a few weeks I will set MadelineProto 4.0 **as default** with `madeline.php`:
tell about restart
tell about madeline.php loading in the same dire
remind about using the define
remind about using the define
fix trimming newlines in beginning
weird splitting mmm ```

View File

@ -75,11 +75,12 @@ class FeedLoop extends ResumableSignalLoop
yield $this->parse($updates);
$updates = null;
}
if ($this->parsedUpdates) {
foreach ($this->parsedUpdates as $update) {
while ($this->parsedUpdates) {
$parsedUpdates = $this->parsedUpdates;
$this->parsedUpdates = [];
foreach ($parsedUpdates as $update) {
yield $API->save_update_async($update);
}
$this->parsedUpdates = [];
$this->API->signalUpdate();
}
}