Skip to content

Conversation

@ivkalita
Copy link
Contributor

@ivkalitaivkalita commented Jan 15, 2018

@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 :)

@WyriHaximus
Copy link
Member

Hey @kaduev13 yes your PR is still wanted, in fact the plan was to take over and finish your PR once v0.5.0 gone out. Will look into this one later today or tomorrow 👍 .

@ivkalitaivkalitaforce-pushed the ext-ev-loop branch 2 times, most recently from 405cb25 to 41018f5CompareJanuary 15, 2018 20:48
Copy link
Member

@clueclue left a 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 👍

},
function ($signal){
if ($this->signals->count($signal) === 0){
unset($this->signalEvents[$signal]);
Copy link
Member

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?

Copy link
ContributorAuthor

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.

privatefunctiongetStreamListenerClosure($stream, callable$listener)
{
returnfunction () use ($stream, $listener){
call_user_func($listener, $stream, $this);
Copy link
Member

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.

Copy link
ContributorAuthor

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)){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor CS issue.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, thank you :)

});

$this->assertRunSlowerThan(1.5);
$this->assertRunSlowerThan(2);
Copy link
Member

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?

Copy link
ContributorAuthor

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.

@ivkalitaivkalitaforce-pushed the ext-ev-loop branch 2 times, most recently from 97d946c to 8aef041CompareJanuary 16, 2018 16:04
@ivkalita
Copy link
ContributorAuthor

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 $f identifier? Why not just

function ($signal){$this->signalEvents[$signal] = newSignalEvent(function () use ($signal){$this->signals->call($signal)}, $signal); $this->loop->add($this->signalEvents[$signal])}

@WyriHaximus
Copy link
Member

@kaduev13 The issue in PHP 5.x is that the callable we're calling $this->signals->call($signal); can get cleaned up by the engine while we're still in it causing odd errors. By referencing $f and juggling it again $g we ensure the engine keeps it around for after the $this->signals->call($signal);.

@ivkalita
Copy link
ContributorAuthor

@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
Copy link
Member

@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
Copy link
ContributorAuthor

@WyriHaximus, thank you! Unfortunately, the build url you provided is for commit, that does not exist. I'll try to reproduce this behavior.

@WyriHaximus
Copy link
Member

@kaduev13 yes correct/sorry about that the commits where squashed just before merging to keep a clean commit log.

@ivkalita
Copy link
ContributorAuthor

@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 ExtEvLoop to ensure that everything will work well.
@clue, I fixed issues you have pointed at, review this changes again, please :)

@clue
Copy link
Member

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).

@clueclue changed the title Implement ExtEvLoop.Implement ExtEvLoop (PECL ext-ev)Feb 7, 2018
@ivkalitaivkalitaforce-pushed the ext-ev-loop branch 2 times, most recently from 12d714f to 242fc11CompareFebruary 28, 2018 17:16
@ivkalita
Copy link
ContributorAuthor

@clue nice work with signals, thank you! I rebased this branch onto master, review pls =)

ExtEvLoop implements event loop based on PECL ev extension.
Copy link
Member

@WyriHaximusWyriHaximus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :shipit:

Copy link
Member

@clueclue left a 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! :shipit: 🎉

publicfunctionisTimerActive(TimerInterface$timer)
{
return$this->timers->contains($timer);
}
Copy link
Member

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
Copy link
Member

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
Copy link
ContributorAuthor

@clue thank you for the review :) I fixed these issues.

clue
clue approved these changes Apr 8, 2018
Copy link
Member

@clueclue left a 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! :shipit: 🎉

jsor
jsor approved these changes Apr 8, 2018
@WyriHaximusWyriHaximus merged commit 5511b21 into reactphp:masterApr 8, 2018
@WyriHaximus
Copy link
Member

Awesome, thank you 👍 !

@ivkalita
Copy link
ContributorAuthor

Great to know that it's merged! Thank you!

@WyriHaximus
Copy link
Member

@kaduev13 v0.5.1

@WyriHaximus
Copy link
Member

@kaduev13 FYI I've been running it in production for a week now, as expected no issue what so ever. Well done 👍

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@ivkalita@WyriHaximus@clue@jsor