From c71dd59f87e30f5d5e1d7762f7ce567947b66776 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Wed, 5 Jun 2019 21:41:42 +0200 Subject: [PATCH] Parse updates --- CHANGELOG.md | 6 ++++-- src/danog/MadelineProto/Loop/Update/FeedLoop.php | 7 ++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 28be59b9..5c120d4d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 \ No newline at end of file +remind about using the define + +fix trimming newlines in beginning +weird splitting mmm ``` \ No newline at end of file diff --git a/src/danog/MadelineProto/Loop/Update/FeedLoop.php b/src/danog/MadelineProto/Loop/Update/FeedLoop.php index 068b688b..8cbf58e0 100644 --- a/src/danog/MadelineProto/Loop/Update/FeedLoop.php +++ b/src/danog/MadelineProto/Loop/Update/FeedLoop.php @@ -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(); } }