A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cplusplus.github.io/LWG/issue2856 below:

async should be marked as [[nodiscard]]

This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of Resolved status.

2856. std::async should be marked as [[nodiscard]]

Section: 32.10.9 [futures.async] Status: Resolved Submitter: Andrey Davydov Opened: 2017-01-20 Last modified: 2020-09-06

Priority: 2

View other active issues in [futures.async].

View all other issues in [futures.async].

View all issues with Resolved status.

Discussion:

Because the destructor of the std::future returned from the std::async blocks until the asynchronous operation completes, discarding the std::async return value leads to the synchronous code execution, which is pointless. For example, in the following code

void task1();
void task2();

void foo()
{
  std::async(std::launch::async,  task1),
  std::async(std::launch::async,  task2);
}

void bar()
{
  std::async(std::launch::async,  task1);
  std::async(std::launch::async,  task2);
}

task1 and task2 will be concurrently executed in the function 'foo', but sequentially in the function 'bar'.

[2017-01-27 Telecon]

Priority 2; Nico to provide wording.

[2017-03-04, Kona]

This should be handled by Nico's paper P0600.

Proposed resolution:

Resolved by adoption of P0600 in Albuquerque


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4