Creating a future/promise object
Sebastiaan Koppe via Digitalmars-d
digitalmars-d at puremagic.com
Tue Jul 7 08:11:21 PDT 2015
On Monday, 6 July 2015 at 20:56:04 UTC, Frank Pagliughi wrote:
> void set_result(int retCode) {
> synchronized (mut) {
> this.retCode = retCode;
> completed = true;
> cond.notify();
> }
> }
>
> int get_result() {
> synchronized (mut) {
> while (!completed)
> cond.wait();
> return retCode;
> }
Instead of pulling values out, have you considered pushing them?
E.g. by supplying a delegate that gets called when the
asynchronous action completed.
More information about the Digitalmars-d
mailing list