Hi Kenton,

thanks for the clarification.

Are there any plans to allow joining of Promise<void>s without the need for 
allocating a separate Array? I'd think this is a fairly common operation, 
so avoiding a heap-allocated array would be a welcome optimization.

-Johannes

On Friday, September 8, 2017 at 6:34:30 PM UTC+2, Kenton Varda wrote:
>
> Hi Johannes,
>
> Actually I don't think using braced initialization format ever worked, due 
> to the C++ standard's unfortunate decision that elements of an 
> std::initializer_list should be const. My example code there is erroneous.
>
> What you actually need to do is something like:
>
>     auto builder = kj::heapArrayBuilder<kj::Promise<void>>(2);
>     builder.add(kj::mv(promise1));
>     builder.add(kj::mv(promise2));
>     auto joined = kj::joinPromises(builder.finish());
>
> -Kenton
>
> On Fri, Sep 8, 2017 at 2:20 AM, Johannes Zeppenfeld <[email protected] 
> <javascript:>> wrote:
>
>> Hi Kenton,
>>
>> in [1] you give an example of joining two Promise<void>s to produce a 
>> Promise<void> that is fulfilled when both other promises have fulfilled (to 
>> chain a list of related promises, avoiding a TaskSet and allowing to wait 
>> on the result).
>>
>> In Capnp 6.0.1 using g++ 5.4.0 this gives me the following error:
>>
>> error: no matching function for call to ‘joinPromises(<brace-enclosed 
>> initializer list>)’
>>    tasks = kj::joinPromises({kj::mv(tasks), kj::mv(newTask)});
>>
>> /usr/local/include/kj/async.h:312:24: note: candidate: kj::Promise<void> 
>> kj::joinPromises(kj::Array<kj::Promise<void> >&&)
>>    friend Promise<void> joinPromises(Array<Promise<void>>&& promises);
>>                         ^
>> /usr/local/include/kj/async.h:312:24: note:   no known conversion for 
>> argument 1 from ‘<brace-enclosed initializer list>’ to 
>> ‘kj::Array<kj::Promise<void> >&&’
>>
>> Has something changed here to make this no longer possible? Do I have to 
>> use an ArrayBuilder? Is there some other way to join Promise<void>s without 
>> needing to allocate an Array?
>>
>> Thanks!
>> Johannes
>>
>>
>> [1] 
>> https://github.com/capnproto/capnproto/issues/286#issuecomment-185975985
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Cap'n Proto" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> Visit this group at https://groups.google.com/group/capnproto.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at https://groups.google.com/group/capnproto.

Reply via email to