Skip to content
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

PeclEvLoop: Add new PeclEvLoop (PECL ext-ev) #25

Closed
wants to merge 2 commits into from

Conversation

markkimsal
Copy link

When I download the pecl extension for PHP, the LibEvLoop loop driver is not instantiated and used. The pecl extension documented on php.net does not match the code in LibEvLoop.

This feature branch adds a new driver - PeclEvLoop - that matches the documented libev pecl extension on php.net. The code closely resembles LibEvLoop except some class names and parameter orders are changed.

The existing libev driver seems to function only with a non-official,
out of date libev extension for PHP.  This PeclEvLoop class is a very
similar clone of the LibEvLoop library but for the officially
documented libev extension.

Changes are mostly to constants and function parameter order.
@WyriHaximus
Copy link
Member

Will give it a run but looks good on first sight 👍

@clue
Copy link
Member

clue commented Apr 12, 2015

👍 on getting this in!

Admittedly I haven't looked into testing this either so far.. Any instructions on how to set this up? Bonus points for adding this to the .travis.yml so that we'll actually test this :)

@steverhoades
Copy link
Contributor

Just an FYI this was already implemented in #12 , there are some issues currently with the extension in regards to segfaulting which is keeping it from moving forward.

@giggsey
Copy link

giggsey commented Nov 26, 2015

Any movement on this or #12?

There have been 2 more 'stable' releases to pecl-ev since the last comments on these two issues.

@markkimsal
Copy link
Author

@giggsey I believe the branch is mostly working but I cannot test it because of problems with AbstractLoopTest class. The class uses a temporary memory stream to do its reading and writing, but libraries outside of core ZF cannot use polling on such a stream because it is not a real file handle.

Another problem is that the test assumes callbacks happen synchronously, and this isn't the case with pecl's LibEv. When you run the loop one time with libev the method will return control to PHP immediately. The only way to wait for control until callbacks finish is to completely hand-off program control forever until all callbacks have unregistered themselves from the libev loop. Phpunit's expectOutputString is used a lot in the abstract test class and libev's execution of callbacks is not guaranteed by the time the test method finishes.

There is a segfault after phpunit runs, but this could be related to shutdown clean-up and doesn't seem to disrupt the tests.

@frickenate
Copy link

Any progress on this? This maintained pecl extension has been updated to work with php 7 in a development version (pecl install ev-dev), whereas the developer of the existing php-libev package has indicated that php 7 support is unlikely to happen anytime soon.

This is a unfortunate, considering that libev is supposed to be a modern slimmer version of libevent... but we're stuck using libevent on php 7 at the moment.

@shouze
Copy link

shouze commented Apr 17, 2016

Any progress? Should be cool to merge, this is the only solution ATM for libev+php7.
@markkimsal @ How can we help? Looks like #12 is pretty old, maybe we should close both #25 & #12 and start over & take the best of the 2 PRs?


public function __construct()
{
$this->loop = EvLoop::defaultLoop();
Copy link

@shouze shouze Apr 17, 2016

Choose a reason for hiding this comment

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

Why not new \EvLoop() here?

public function cancelTimer(TimerInterface $timer)
{
if (isset($this->timerEvents[$timer])) {
$event = $this->timerEvents->get($timer);

Choose a reason for hiding this comment

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

$event = $this->timerEvents[$timer];

Copy link

@rhclayto rhclayto Mar 17, 2017

Choose a reason for hiding this comment

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

Correct, there's no get method on SplObjectStorage: http://php.net/manual/en/class.splobjectstorage.php

@markkimsal
Copy link
Author

I can't do any more work on this until react's unit test class is cleaned up wrt my previous comments. It's basically impossible to test any async loop drivers. AFAIK this extension is good, but it's not testable and I can't make it testable.

@clue
Copy link
Member

clue commented Nov 9, 2016

@markkimsal I share your concern and I've love to get this in. What do you suggest we do here?

Technically, you're not required to extend the AbstractLoopTest class, so you may as well implement your own test cases. Otherwise, you may overwrite only certain methods and make sure they're adjusted to your particular loop.

As long as we make sure the loop is fully tested and any differences to existing loops are properly covered and documented(!), I'm fine with either 👍

@clue clue changed the title Feature/pecl ev PeclEvLoop: New PeclEvLoop Feb 8, 2017
@clue clue changed the title PeclEvLoop: New PeclEvLoop PeclEvLoop: Add new PeclEvLoop (libev) Feb 8, 2017
@clue
Copy link
Member

clue commented Feb 8, 2017

I'd like to make this actionable :shipit:

What is the current status here? How is this related to #12?

Is there still interest in this ticket or can either be closed?

@clue clue mentioned this pull request Mar 15, 2017
@clue clue changed the title PeclEvLoop: Add new PeclEvLoop (libev) PeclEvLoop: Add new PeclEvLoop (PECL ext-ev) Dec 4, 2017
@clue
Copy link
Member

clue commented Dec 4, 2017

Thank you for working on this and helping push this forward! This is kind of an old PR and it looks like #97 is the most up to date version of this feature, so I'm closing this one in favor of the newer PR :shipit: This should help us focusing on shipping this in a future version 👍

@clue clue closed this Dec 4, 2017
Sign up for free to 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.

9 participants