Promises in D
Calvin P
cloudlessapp at gmail.com
Wed Apr 7 16:14:15 UTC 2021
On Wednesday, 7 April 2021 at 06:51:12 UTC, Vladimir Panteleev
wrote:
>
> Going even lower, there are callbacks/delegates. In JavaScript,
> there are few reasons to use callbacks today, because they are
> much less composable and don't provide much other benefit.
> However, there is one reason in D where callbacks trump both
> fibers and promises: a callback's caller controls the lifetime
> of the passed values, whereas promises require that their held
> value either is owned by the promise, or has infinite lifetime
> (i.e. is immutable and on the heap). So, if you were to write a
> low-level high-performance networking library, you would
> probably want to have:
>
> [...]
I use refCount to pass resource with promises provide by QuickJS,
It also work well with async IO code based on D.
More information about the Digitalmars-d
mailing list