Thread overview |
---|
July 20, 2017 Array of Template instantiations | ||||
---|---|---|---|---|
| ||||
Hi, i don't even know if the subject makes any sense :) What i want to achieve is: instead of making: >auto v_a = async( &load , queryA ); >auto v_b = async( &load , queryB ); >auto v_c = async( &load , queryC ); ( async is a function from vibe and returns a "Future" - see http://vibed.org/api/vibe.core.concurrency/async for the async ) i want to something like this: >WHAT_TYPE[] futures; >futures ~= async( &load , queryA ); >futures ~= async( &load , queryB ); >futures ~= async( &load , queryC ); And then collect the results somwhere later like: >foreach(WHAT_TYPE future ; futures) >{ > writeln( future.getResult() ); >} The Problem is, i dont know what type WHAT_TYPE is / i don´t know how to build a loopable something of futures. |
July 20, 2017 Re: Array of Template instantiations | ||||
---|---|---|---|---|
| ||||
Posted in reply to Alex | On Thursday, 20 July 2017 at 12:33:43 UTC, Alex wrote: > The Problem is, i dont know what type WHAT_TYPE is / i don´t know how to build a loopable something of futures. Ok, i think i understood now. my function `load` returns `KpiResponseEntity` so >Future!(KpiResponseEntity)[] futures; seems to work |
July 20, 2017 Re: Array of Template instantiations | ||||
---|---|---|---|---|
| ||||
Posted in reply to Alex | On Thursday, 20 July 2017 at 13:11:56 UTC, Alex wrote:
> On Thursday, 20 July 2017 at 12:33:43 UTC, Alex wrote:
>> The Problem is, i dont know what type WHAT_TYPE is / i don´t know how to build a loopable something of futures.
>
> Ok, i think i understood now.
>
> my function `load` returns `KpiResponseEntity`
> so
>>Future!(KpiResponseEntity)[] futures;
> seems to work
To get the type you can also use `typeof`.
alias ResponseType = typeof(async(&load , queryA ));
ResponseType[] futures;
futures ~= async( &load , queryA );
futures ~= async( &load , queryB );
futures ~= async( &load , queryC );
|
Copyright © 1999-2021 by the D Language Foundation