4 ms·
My teams/company uses it all over, so maybe depends on the context you work in? And FWIW, this explicit form is often unnecessary - if you kick off each task t
by Serow225 6y ago
My teams/company uses it all over, so maybe depends on the context you work in?
And FWIW, this explicit form is often unnecessary - if you kick off each task they will run in parallel and then just await each task only when the result is needed, it can look a lot cleaner:
var p_t = GetUserPermission(username);
var c_t = GetServerConfig();
var m_t = GetMessageOfTheDay();
var foo = isAuthorized(await p_t);
// more code here
var msg = ( (await c_t).ServerName + await m_t) );
- littlestymaar 6y agoTrue, this doesn't work in Rust though, because nothing at all happens before the first time you poll a future, so you need an explicit task (but as other pointed out, it's pretty straightforward thanks to the `join!` macro).
- Serow225 6y agoSame as F# It uses 'cold' tasks, unlike C# that uses 'hot' tasks that start running immediately. But the F# way can compose in more advanced ways.