Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 131
Implement ExtEvLoop (PECL ext-ev)#148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Conversation
ivkalita commented Jan 15, 2018 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
WyriHaximus commented Jan 15, 2018
Hey @kaduev13 yes your PR is still wanted, in fact the plan was to take over and finish your PR once |
405cb25 to 41018f5Compare
clue left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kaduev13 Thank you so much for keeping up with this and filing an update! 👍
I've found some minor issues below, otherwise LGTM 👍
src/ExtEvLoop.php Outdated
| }, | ||
| function ($signal){ | ||
| if ($this->signals->count($signal) === 0){ | ||
| unset($this->signalEvents[$signal]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably stop() the watcher before clearing this reference, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's very important to stop watcher before clearing the reference. Fixed.
src/ExtEvLoop.php Outdated
| privatefunctiongetStreamListenerClosure($stream, callable$listener) | ||
| { | ||
| returnfunction () use ($stream, $listener){ | ||
| call_user_func($listener, $stream, $this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The additional $loop argument has been removed via #110, so the last parameter should be omitted here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for pointing it! I removed this argument.
src/Factory.php Outdated
| } elseif (class_exists('EvLoop', false)){ | ||
| returnnewExtEvLoop(); | ||
| } | ||
| elseif (class_exists('EventBase', false)){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor CS issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, thank you :)
tests/AbstractLoopTest.php Outdated
| }); | ||
| $this->assertRunSlowerThan(1.5); | ||
| $this->assertRunSlowerThan(2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the motivation for this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought that there was a problem with floating point accuracy, but it was not. It should be changed to the previous 1.5 value. Fixed.
97d946c to 8aef041Compareivkalita commented Jan 16, 2018
Also, I noticed that other loops implementations contains such code for signals callbacks: function ($signal){$this->signalEvents[$signal] = newSignalEvent($f = function () use ($signal, &$f){$this->signals->call($signal); // Ensure there are two copies of the callable around until it has been executed.// For more information see: https://bugs.php.net/bug.php?id=62452// Only an issue for PHP 5, this hack can be removed once PHP 5 support has been dropped.$g = $f; $f = $g}, $signal); $this->loop->add($this->signalEvents[$signal])},My question is why using the function ($signal){$this->signalEvents[$signal] = newSignalEvent(function () use ($signal){$this->signals->call($signal)}, $signal); $this->loop->add($this->signalEvents[$signal])} |
WyriHaximus commented Jan 16, 2018
@kaduev13 The issue in PHP 5.x is that the callable we're calling |
ivkalita commented Jan 16, 2018
@WyriHaximus, I checked that issue, but, as I understood, this bug is about aliasing. I mean, that this code will randomly fail: function ($signal){$this->signalEvents[$signal] = newSignalEvent($f = function () use ($signal, &$f){$this->signals->call($signal)}, $signal); $this->loop->add($this->signalEvents[$signal])}but this one should not (no alias == no problems?): function ($signal){$this->signalEvents[$signal] = newSignalEvent(function () use ($signal){$this->signals->call($signal)}, $signal); $this->loop->add($this->signalEvents[$signal])} |
WyriHaximus commented Jan 16, 2018
@kaduev13 feel free to prove me wrong, I don't like the solution for that bug so if we can get rid of it that would be great 👍 . Also be sure to check signal example to be sure. IIRC this is one of the failing builds for that bug: https://travis-ci.org/reactphp/event-loop/jobs/258431073#L1054 |
ivkalita commented Jan 17, 2018
@WyriHaximus, thank you! Unfortunately, the build url you provided is for commit, that does not exist. I'll try to reproduce this behavior. |
WyriHaximus commented Jan 17, 2018
@kaduev13 yes correct/sorry about that the commits where squashed just before merging to keep a clean commit log. |
ivkalita commented Jan 23, 2018
@WyriHaximus sorry, I didn't have enough time to completely test the issue with lambdas. I'll continue my investigation later. I added similar workaround to |
clue commented Feb 6, 2018
@kaduev13 Very good point about signal handling callbacks! I've just filed #150, once this is in, this should be simplified significantly (this will likely cause a merge conflict here though). |
12d714f to 242fc11Compareivkalita commented Feb 28, 2018
@clue nice work with signals, thank you! I rebased this branch onto master, review pls =) |
ExtEvLoop implements event loop based on PECL ev extension.
WyriHaximus left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM ![]()
clue left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kaduev13 Again, thank you so much for keeping up with this and putting the effort into keeping this updated! 👍
Only this one minor remark, otherwise I'm happy to get this in finally!
🎉
src/ExtEvLoop.php Outdated
| publicfunctionisTimerActive(TimerInterface$timer) | ||
| { | ||
| return$this->timers->contains($timer); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method has been removed from the public interface with #133, so this should probably be removed here.
| This loop is known to work with PHP 5.4 through PHP 7+. | ||
| #### ExtEvLoop |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should also be added to the TOC above 👍
ivkalita commented Apr 6, 2018
@clue thank you for the review :) I fixed these issues. |
clue left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thank you for the update!
🎉
WyriHaximus commented Apr 8, 2018
Awesome, thank you 👍 ! |
ivkalita commented Apr 9, 2018
Great to know that it's merged! Thank you! |
WyriHaximus commented Apr 9, 2018
@kaduev13 |
WyriHaximus commented Apr 16, 2018
@kaduev13 FYI I've been running it in production for a week now, as expected no issue what so ever. Well done 👍 |
@clue, @WyriHaximus, @jsor hello!
Finally I fixed my old pull request. I'm really sorry that it took so long for me.
I hope, that this feature still wanted and needed :)