Created on 2009-11-17.00:00:00 last changed 170 months ago
Proposed resolution:
Replace [futures.shared_future]p22 with the following:
Effects: If the associated state
contains a deferred function, executes the deferred function. Otherwise, blocks until the associated state is ready.was created by a promise or packaged_task object, block until the associated state is ready. If the associated state is associated with a thread created for an async call ([futures.async]), as if associated-thread.join().If the associated state contains a deferred function, calls to wait() on all shared_future objects that share the same associated state are serialized. The first call to wait() that shares a given associated state executes the deferred function and stores the return value or exception in the associated state.
Synchronization: if the associated state was created by a promise object, the completion of set_value() or set_exception() to that promise happens before ([intro.multithread]) wait() returns. If the associated state was created by a packaged_task object, the completion of the associated task happens before wait() returns. If the associated state is associated with a thread created for an async call ([futures.async]), the completion of the associated thread happens-before wait() returns.
If the associated state contained a deferred function, the invocation of the deferred function happens-before any call to wait() on a future that shares that state returns.
Rationale:
Solved by N3058.
[
2010 Pittsburgh: Moved to NAD EditorialResolved. Rationale added below.
]
If a shared_future is constructed with the result of an async call with a deferred function, and two or more copies of that shared_future are created, with multiple threads calling get(), it is not clear which thread runs the deferred function. [futures.shared_future]p22 from N3000 says (minus editor's note):
Effects: if the associated state contains a deferred function, executes the deferred function. Otherwise, blocks until the associated state is ready.
In the absence of wording to the contrary, this implies that every thread that calls wait() will execute the deferred function.
History | |||
---|---|---|---|
Date | User | Action | Args |
2010-12-05 00:09:22 | admin | set | messages: + msg5456 |
2010-12-05 00:09:22 | admin | set | messages: + msg5455 |
2010-12-05 00:09:22 | admin | set | messages: + msg5454 |
2009-11-17 00:00:00 | admin | create |