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

### 2142. `packaged_task::operator()` synchronization too broad?

Section: 32.9.10.2 [futures.task.members] Status: C++14 Submitter: Pete Becker Opened: 2012-03-12 Last modified: 2016-01-28

Priority: Not Prioritized

View all other issues in [futures.task.members].

View all issues with C++14 status.

Discussion:

According to 32.9.10.2 [futures.task.members] p.18:

> [A] successful call to [`packaged_task::`]`operator()` synchronizes with a call to any member function of a `future` or `shared_future` object that shares the shared state of `*this`.

This requires that the call to `operator()` synchronizes with calls to `future::wait_for`, `future::wait_until`, `shared_future::wait_for`, and `shared_future::wait_until`, even when these functions return because of a timeout.

[2012, Portland: move to Open]

If it said "a successful return from" (or "a return from" to cover exceptions) the problem would be more obvious.

Detlef: will ask Anthony Williams to draft some wording.

Moved to open (Anthony drafted to draft)

[2013-09, Chicago: move to Ready]

Anthony's conclusion is that the offending paragraph is not needed. Already included in the statement that the state is made ready.

Recommendation: Remove 32.9.10.2 [futures.task.members] p18 (the synchronization clause). Redundant because of 32.9.5 [futures.state] p9.

Moved to Ready

Proposed resolution:

This wording is relative to N3691.

1. Remove 32.9.10.2 [futures.task.members] p18 as indicated:

   >     void operator()(ArgTypes... args);

   > > […]

   > > -18- Synchronization: a successful call to `operator()` synchronizes with (1.10) a call to any member function of a `future` or `shared_future` object that shares the shared state of `*this`. The completion of the invocation of the stored task and the storage of the result (whether normal or exceptional) into the shared state synchronizes with (1.10) the successful return from any member function that detects that the state is set to ready. [Note: `operator()` synchronizes and serializes with other functions through the shared state. — end note]