async-interop / event-loop

An event loop interface for interoperability in PHP.
MIT License
170 stars 9 forks source link

Standard sync implementation #140

Closed joelwurtz closed 7 years ago

joelwurtz commented 7 years ago

Don't know if this is the scope of this project, but would a "fake" implementation of an async driver which don't use any implementation and instead call the user land code in a sync way have this place here ?

This is mainly for people who wants to wrote library being compatible on both worlds, so you would in this case write your code in a async way (using promise and other stuff) and then use a default driver which will be this implementation.

So by default user of our library don't have to learn about the whole async stuff, and can then upgrade their knowledge when they want to switch to a "true" async implementation.

kelunik commented 7 years ago

@joelwurtz I think it's fine for libraries doing that to make the user add a single line to their composer.json. You can recommend a specific implementation.

bwoebi commented 7 years ago

@joelwurtz the main problem with a sync implementation is that timeouts won't work. - Things will actually somewhat work… but once the other end gets unresponsive sometime, the program will hang.

joelwurtz commented 7 years ago

In fact i think i can resolve my use case by only use promise which are easy to implement in a sync context, so maybe having more a standard promise "sync" would be helpful, still not sure if this is relevant to have that in the spec ?

bwoebi commented 7 years ago

Well, the Promises are decoupled from the event-loop and sync/asnyc notion in general.

joelwurtz commented 7 years ago

Yes, so not relevant IMO, sorry for disturbing ^^