Promises in D
Vladimir Panteleev
thecybershadow.lists at gmail.com
Thu Apr 8 05:42:28 UTC 2021
On Wednesday, 7 April 2021 at 21:20:11 UTC, Sebastiaan Koppe
wrote:
> Having been inspired by the Senders/Receivers C++ proposal
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p0443r14.html I started an implementation here https://github.com/symmetryinvestments/concurrency [*]
>
> I initially dismissed the proposal completely, and it took me
> at least a few months before I realized the beauty of it.
>
> Now, I see them as fundamental building blocks in asynchronous
> code. They are cancelable, they avoid unnecessary allocations
> and synchronizations, and above all, they adhere to the
> principles of structured concurrency.
>
> This is a good talk from eric niebler about them:
>
> https://www.youtube.com/watch?v=h-ExnuD6jms
>
> [*] it are still early days but it implements a fair bit of
> useful asynchronous algorithms.
Thanks!
Looking into this a bit, I understand that this doesn't quite
attempt to solve the same problems.
The document and the talk begins about how this is aimed to be a
tool at doing parallel/asynchronous computations. Promises and
async/await are mainly concerned about scheduling execution of
code on the CPU asynchronously while avoiding waiting for
blocking operations (network or I/O). Everything still runs on
one thread.
I wasn't able to quickly divine if this approach allows avoiding
the value copy as delegates do. If they do, would you mind
explaining how (such as in the case that a promise/equivalent is
resolved immediately, before a result handler is attached)?
More information about the Digitalmars-d
mailing list