amphp / amp

A non-blocking concurrency framework for PHP applications. 🐘

Home Page:https://amphp.org/amp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Shouldn't Future::finally() pass the future data to the provided callback?

dmiedev opened this issue · comments

I'm a little perplexed by the fact that you can't obtain the future data from the arguments (as nothing is passed).

You mean future resolved data pass to finally callback?

Yes...

Why do you except / need it there?

Well, I didn't find a way to await for the value without blocking the thread. If I understand correctly, await() is not non-blocking. I guess there is also map(), maybe I could use that

You should do something in map() callback that depends on resolved value.
And await block your code executing of current stack, but no block your process.
You can have lots of coroutine running concurrent.

await just blocks the current fiber, but if you want to avoid that, use map() or catch(), depending on whether you want to work with the successful completion value or error. finally() is always called, like a finally block, and the result might be an error or not, so we don't provide any info there. If you need different behavior on success / error, use map() / catch().