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

Avoid dependency on the Loop #18

Closed
joelwurtz opened this issue Nov 15, 2016 · 5 comments
Closed

Avoid dependency on the Loop #18

joelwurtz opened this issue Nov 15, 2016 · 5 comments

Comments

@joelwurtz
Copy link

joelwurtz commented Nov 15, 2016

Hi,

Actually when executing a callback on the when method this spec specify that :

If one of the callbacks throws an Exception or Throwable, it MUST be rethrown in a callable passed to Loop::defer so Loop::onError can be properly invoked by the loop.

This specification introduce a high dependency on the event-loop for people creating a promise implementation.

This is problematic for our use case at https://github.com/php-http, because we use the Promise as the main API return value for our plugin system (see https://github.com/php-http/client-common). This allow us to use the same API for async and sync calls as it relatively easy to go from async API to sync API (you just need to wait or use already resolved promise) so we can write code that are compatible on both worlds.

However having this dependency on the loop will force all people using the plugin system to have an event loop even in the sync mode.

Is there a way to avoid having this dependency ?

@joelwurtz
Copy link
Author

Oops just see : https://github.com/async-interop/promise/pull/17/commits which partially resolved our use case, but is there a way to detect if a loop is running appart from getting the driver and tracking the exception ?

@WyriHaximus
Copy link
Member

@joelwurtz FYI here is some more information regarding the loop: reactphp/promise#64 (comment) (doesn't answer your latest question though)

@kelunik
Copy link
Member

kelunik commented Nov 15, 2016

@joelwurtz We already discussed that yesterday, we will completely remove the dependency. I'll post a PR soon.

@joelwurtz
Copy link
Author

We already discussed that yesterday, we will completely remove the dependency. I'll post a PR soon.

Nice, is this discussion publicly available somewhere ? (very interessed to see the reflexion about this)

@kelunik
Copy link
Member

kelunik commented Nov 15, 2016

PR is linked. Discussion is publicly available here: http://chat.stackoverflow.com/transcript/message/34040899#34040899

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants