Programming Languages — Technical specification for C++ extensions for concurrency

Since the extensions described in this ISO/IEC TS 19571:2016 are experimental and not part of the C++ standard library, they should not be declared directly within namespace std. Unless otherwise specified, all components described in this technical specification either: - modify an existing interface in the C++ Standard Library in-place, - are declared in a namespace whose name appends ::experimental::concurrency_v1 to a namespace defined in the C++ Standard Library, such as std, or - are declared in a subnamespace of a namespace described in the previous bullet, whose name is not the same as an existing subnamespace of namespace std. Each header described in this ISO/IEC TS 19571:2016 shall import the contents of std::experimental::concurrency_v1 into std::experimental as if by namespace std { namespace experimental { inline namespace concurrency_v1 {} } }

Langages de programmation — Spécification technique pour C ++ Extensions pour la concurrence

General Information

Status
Withdrawn
Publication Date
18-Jan-2016
Withdrawal Date
18-Jan-2016
Current Stage
9599 - Withdrawal of International Standard
Start Date
25-Aug-2021
Completion Date
12-Feb-2026
Technical specification

ISO/IEC TS 19571:2016 - Programming Languages -- Technical specification for C++ extensions for concurrency

English language
19 pages
sale 15% off
Preview
sale 15% off
Preview

Get Certified

Connect with accredited certification bodies for this standard

BSI Group

BSI (British Standards Institution) is the business standards company that helps organizations make excellence a habit.

UKAS United Kingdom Verified

NYCE

Mexican standards and certification body.

EMA Mexico Verified

Sponsored listings

Frequently Asked Questions

ISO/IEC TS 19571:2016 is a technical specification published by the International Organization for Standardization (ISO). Its full title is "Programming Languages — Technical specification for C++ extensions for concurrency". This standard covers: Since the extensions described in this ISO/IEC TS 19571:2016 are experimental and not part of the C++ standard library, they should not be declared directly within namespace std. Unless otherwise specified, all components described in this technical specification either: - modify an existing interface in the C++ Standard Library in-place, - are declared in a namespace whose name appends ::experimental::concurrency_v1 to a namespace defined in the C++ Standard Library, such as std, or - are declared in a subnamespace of a namespace described in the previous bullet, whose name is not the same as an existing subnamespace of namespace std. Each header described in this ISO/IEC TS 19571:2016 shall import the contents of std::experimental::concurrency_v1 into std::experimental as if by namespace std { namespace experimental { inline namespace concurrency_v1 {} } }

Since the extensions described in this ISO/IEC TS 19571:2016 are experimental and not part of the C++ standard library, they should not be declared directly within namespace std. Unless otherwise specified, all components described in this technical specification either: - modify an existing interface in the C++ Standard Library in-place, - are declared in a namespace whose name appends ::experimental::concurrency_v1 to a namespace defined in the C++ Standard Library, such as std, or - are declared in a subnamespace of a namespace described in the previous bullet, whose name is not the same as an existing subnamespace of namespace std. Each header described in this ISO/IEC TS 19571:2016 shall import the contents of std::experimental::concurrency_v1 into std::experimental as if by namespace std { namespace experimental { inline namespace concurrency_v1 {} } }

ISO/IEC TS 19571:2016 is classified under the following ICS (International Classification for Standards) categories: 35.060 - Languages used in information technology. The ICS classification helps identify the subject area and facilitates finding related standards.

ISO/IEC TS 19571:2016 is available in PDF format for immediate download after purchase. The document can be added to your cart and obtained through the secure checkout process. Digital delivery ensures instant access to the complete standard document.

Standards Content (Sample)


TECHNICAL ISO/IEC TS
SPECIFICATION 19571
First edition
2016-02-01
Programming Languages —
Technical Specification for C++
Extensions for Concurrency
Langages de programmation — Spécification technique pour C ++
Extensions pour la concurrence
Reference number
©
ISO/IEC 2016
© ISO/IEC 2016, Published in Switzerland
All rights reserved. Unless otherwise specified, no part of this publication may be reproduced or utilized otherwise in any form
or by any means, electronic or mechanical, including photocopying, or posting on the internet or an intranet, without prior
written permission. Permission can be requested from either ISO at the address below or ISO’s member body in the country of
the requester.
ISO copyright office
Ch. de Blandonnet 8 • CP 401
CH-1214 Vernier, Geneva, Switzerland
Tel. +41 22 749 01 11
Fax +41 22 749 09 47
copyright@iso.org
www.iso.org
ii © ISO/IEC 2016 – All rights reserved

Contents
Foreword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . v
1 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1 Namespaces, headers, and modifications to standard classes . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Future plans (Informative) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3 Feature-testing recommendations (Informative) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2 Improvements to std::future and Related APIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.1 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.2 Header synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.3 Class template future . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.4 Class template shared_future . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.5 Class template promise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.6 Class template packaged_task . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.7 Function template when_all . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.8 Class template when_any_result . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.9 Function template when_any . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.10 Function template make_ready_future . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.11 Function template make_exceptional_future . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3 Latches and Barriers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.1 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.2 Terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.3 Latches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.4 Header synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.5 Class latch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.6 Barrier types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.7 Header synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.8 Class barrier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.9 Class flex_barrier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
4 Atomic Smart Pointers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
4.1 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
4.2 Header synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
4.3 Class template atomic_shared_ptr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
4.4 Class template atomic_weak_ptr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
© ISO/IEC 2016 — All rights reserved iii

Foreword
ISO (the International Organization for Standardization) is a worldwide federation of national standards bodies (ISO
member bodies). The work of preparing International Standards is normally carried out through ISO technical
committees. Each member body interested in a subject for which a technical committee has been established has the right
to be represented on that committee. International organizations, governmental and non-governmental, in liaison with
ISO, also take part in the work. ISO collaborates closely with the International Electrotechnical Commission (IEC) on all
matters of electrotechnical standardization.
The procedures used to develop this document and those intended for its further maintenance are described in the ISO/
IEC Directives, Part 1. In particular the different approval criteria needed for the different types of ISO documents should
be noted. This document was drafted in accordance with the editorial rules of the ISO/IEC Directives, Part 2.
www.iso.org/directives
Attention is drawn to the possibility that some of the elements of this document may be the subject of patent rights. ISO
shall not be held responsible for identifying any or all such patent rights. Details of any patent rights identified during the
development of the document will be in the Introduction and/or on the ISO list of patent declarations received.
www.iso.org/patents
Any trade name used in this document is information given for the convenience of users and does not constitute an
endorsement.
For an explanation on the meaning of ISO specific terms and expressions related to conformity assessment, as well as
information about ISO's adherence to the WTO principles in the Technical Barriers to Trade (TBT) see the following
URL: Foreword - Supplementary information
The committee responsible for this document is ISO/IEC JTC1.
iv © ISO/IEC 2016 — All rights reserved

TECHNICAL SPECIFICATION ISO/IEC TS 19571:2016(E)
Programming Languages — Technical Specification for C++
Extensions for Concurrency
1 General [general]
1.1 Namespaces, headers, and modifications to standard classes [general.namespaces]
Since the extensions described in this technical specification are experimental and not part of the C++ standard library,
they should not be declared directly within namespace std. Unless otherwise specified, all components described in this
technical specification either:
— modify an existing interface in the C++ Standard Library in-place,
— are declared in a namespace whose name appends ::experimental::concurrency_v1 to a namespace defined
in the C++ Standard Library, such as std, or
— are declared in a subnamespace of a namespace described in the previous bullet, whose name is not the same as
an existing subnamespace of namespace std.
Each header described in this technical specification shall import the contents of std::experimental::concurrency_v1
into std::experimental as if by
namespace std {
namespace experimental {
inline namespace concurrency_v1 {}
}
}
Unless otherwise specified, references to other entities described in this technical specification are assumed to be
qualified with std::experimental::concurrency_v1::, and references to entities described in the standard are assumed
to be qualified with std::.
Extensions that are expected to eventually be added to an existing header are provided inside the
header, which shall include the standard contents of as if by
#include
New headers are also provided in the directory, but without such an #include.
Table 1 — C++ library headers


1.2 Future plans (Informative) [general.plans]
This section describes tentative plans for future versions of this technical specification and plans for moving content into
future versions of the C++ Standard.
The C++ committee intends to release a new version of this technical specification approximately every year, containing
the library extensions we hope to add to a near-future version of the C++ Standard. Future versions will define their
contents in std::experimental::concurrency_v2, std::experimental::concurrency_v3, etc., with the most recent
implemented version inlined into std::experimental.
When an extension defined in this or a future version of this technical specification represents enough existing practice, it
will be moved into the next version of the C++ Standard by removing the experimental::concurrency_vN segment of its
namespace and by removing the experimental/ prefix from its header's path.
© ISO/IEC 2016 — All rights reserved 1

1.3 Feature-testing recommendations (Informative) [general.feature.test]
For the sake of improved portability between partial implementations of various C++ standards, WG21 (the ISO technical
committee for the C++ programming language) recommends that implementers and programmers follow the guidelines in
this section concerning feature-test macros. [ Note: WG21's SD-6 makes similar recommendations for the C++ Standard
itself. — end note ]
Implementers who provide a new standard feature should define a macro with the recommended name, in the same
circumstances under which the feature is available (for example, taking into account relevant command-line options), to
indicate the presence of support for that feature. Implementers should define that macro with the value specified in the
most recent version of this technical specification that they have implemented. The recommended macro name is
"__cpp_lib_experimental_" followed by the string in the "Macro Name Suffix" column.
Programmers who wish to determine whether a feature is available in an implementation should base that determination
on the presence of the header (determined with __has_include(

)) and the state of the macro with the
recommended name. (The absence of a tested feature may result in a program with decreased functionality, or the relevant
functionality may be provided in a different way. A program that strictly depends on support for a feature can just try to
use the feature unconditionally; presumably, on an implementation lacking necessary support, translation will fail.)
Table 2 — Significant features in this technical specification
Doc. Primary
Title Macro Name Suffix Value Header
No. Section
Improvements to std::future
N4399 2 future_continuations 201505
and Related APIs
N4204 C++ Latches and Barriers 3 latch 201505
N4204 C++ Latches and Barriers 3 barrier 201505
N4260 Atomic Smart Pointers 4 atomic_smart_pointers 201505
2 © ISO/IEC 2016 — All rights reserved

2 Improvements to std::future and Related APIs [futures]
2.1 General [futures.general]
The extensions proposed here are an evolution of the functionality of std::future and std::shared_future. The
extensions enable wait-free composition of asynchronous operations. Class templates std::promise and
std::packaged_task are also updated to be compatible with the updated std::future.
2.2 Header synopsis [header.future.synop]
#include
namespace std {
namespace experimental {
inline namespace concurrency_v1 {
template class promise;
template class promise;
template <> class promise;
template
void swap(promise& x, promise& y) noexcept;
template class future;
template class future;
template <> class future;
template class shared_future;
template class shared_future;
template <> class shared_future;
template class packaged_task; // undefined
template
class packaged_task;
template
void swap(packaged_task&, packaged_task&) noexcept;
template
see below make_ready_future(T&& value);
future make_ready_future();
template
future make_exceptional_future(exception_ptr ex);
template
future make_exceptional_future(E ex);
template
see below when_all(InputIterator first, InputIterator last);
template
© ISO/IEC 2016 — All rights reserved 3

see below when_all(Futures&&. futures);
template
struct when_any_result;
template
see below when_any(InputIterator first, InputIterator last);
template
see below when_any(Futures&&. futures);
} // namespace concurrency_v1
} // namespace experimental
template
struct uses_allocator, Alloc>;
template
struct uses_allocator, Alloc>;
} // namespace std
2.3 Class template future [futures.unique_future]
The specifications of all declarations within this subclause 2.3 and its subclauses are the same as the corresponding
declarations, as specified in C++14 §30.6.6, unless explicitly specified otherwise.
namespace std {
namespace experimental {
inline namespace concurrency_v1 {
template
class future {
public:
future() noexcept;
future(future &&) noexcept;
future(const future&) = delete;
future(future>&&) noexcept;
~future();
future& operator=(const future&) = delete;
future& operator=(future&&) noexcept;
shared_future share();
// retrieving the value
see below get();
// functions to check state
bool valid() const noexcept;
bool is_ready() const;
void wait() const;
template
future_status wait_for(const chrono::duration& rel_time) const;
4 © ISO/IEC 2016 — All rights reserved

template
future_status wait_until(const chrono::time_point& abs_time) const;
// continuations
template
see below then(F&& func);
};
} // namespace concurrency_v1
} // namespace experimental
} // namespace std
future(future>&& rhs) noexcept;
Effects: Constructs a future object from the shared state referred to by rhs. The future becomes ready when one of
the following occurs:
— Both the rhs and rhs.get() are ready. The value or the exception from rhs.get() is stored in the
future's shared state.
— rhs is ready but rhs.get() is invalid. An exception of type std::future_error, with an error condition
of std::future_errc::broken_promise is stored in the future's shared state.
Postconditions:
— valid() == true.
— rhs.valid() == false.
The member function template then provides a mechanism for attaching a continuation to a future object, which will be
executed as specified below.
© ISO/IEC 2016 — All rights reserved 5

template
see below then(F&& func);
Requires: INVOKE(DECAY_COPY (std::forward(func)), std::move(*this)) shall be a valid expression.
Effects: The function creates a shared state that is associated with the returned future object. Additionally,
— When the object's shared state is ready, the continuation
INVOKE(DECAY_COPY(std::forward(func)), std::move(*this)) is called on an unspecified thread
of execution with the call to DECAY_COPY() being evaluated in the thread that called then.
— Any value returned from the continuation is stored as the result in the shared state of the resulting future.
Any exception propagated from the execution of the continuation is stored as the exceptional result in the
shared state of the resulting future.
Returns: When result_of_t(future)> is future, for some type R2, the function returns
future. Otherwise, the function returns future(future)>>. [ Note: The rule
above is referred to as implicit unwrapping. Without this rule, the return type of then taking a callable returning a
future would have been future>. This rule avoids such nested future objects. The type of f2 below
is future and not future>:
[ Example:
future f1 = g();
future f2 = f1.then([](future f) {
future f3 = h();
return f3;
});
— end example ]
— end note ]
Postconditions: valid() == false on the original future. valid() == true on the future returned from then.
[ Note: In case of implicit unwrapping, the validity of the future returned from func cannot be established until after
the completion of the continuation. If it is not valid, the resulting future becomes ready with an exception of type
std::future_error, with an error condition of std::future_errc::broken_promise. — end note ]
bool is_ready() const;
Returns: true if the shared state is ready, otherwise false.
2.4 Class template shared_future [futures.shared_future]
The specifications of all declarations within this subclause 2.4 and its subclauses are the same as the corresponding
declarations, as specified in C++14 §30.6.7, unless explicitly specified otherwise.
namespace std {
namespace experimental {
inline namespace concurrency_v1 {
template
class shared_future {
public:
shared_future() noexcept;
shared_future(const shared_future&) noexcept;
shared_future(future&&) noexcept;
shared_future(future>&& rhs) noexcept;
~shared_future();
6 © ISO/IEC 2016 — All rights reserved

shared_future& operator=(const shared_future&);
shared_future& operator=(shared_future&&) noexcept;
// retrieving the value
see below get();
// functions to check state
bool valid() const noexcept;
bool is_ready() const;
void wait() const;
template
future_status wait_for(const chrono::duration& rel_time) const;
template
future_status wait_until(const chrono::time_point& abs_time) const;
// continuations
template
see below then(F&& func) const;
};
} // namespace concurrency_v1
} // namespace experimental
} // namespace std
shared_future(future>&& rhs) noexcept;
Effects: Constructs a shared_future object from the shared state referred to by rhs. The shared_future becomes
ready when one of the following occurs:
— Both the rhs and rhs.get() are ready. The value or the exception from rhs.get() is stored in the
shared_future's shared state.
— rhs is ready but rhs.get() is invalid. The shared_future stores an exception of type
std::future_error, with an error condition of std::future_errc::broken_promise.
Postconditions:
— valid() == true.
— rhs.valid() == false.
The member function template then provides a mechanism for attaching a continuation to a shared_future object, which
will be executed as specified below.
© ISO/IEC 2016 — All rights reserved 7

template
see below then(F&& func) const;
Requires: INVOKE(DECAY_COPY (std::forward(func)), *this) shall be a valid expression.
Effects: The function creates a shared state that is associated with the returned future object. Additionally,
— When the object's shared state is ready, the continuation
INVOKE(DECAY_COPY(std::forward(func)), *this) is called on an unspecified thread of execution
with the call to DECAY_COPY() being evaluated in the thread that called then.
— Any value returned from the continuation is stored as the result in the shared state of the resulting future.
Any exception propagated from the execution of the continuation is stored as the exceptional result in the
shared state of the resulting future.
Returns: When result_of_t(const shared_future&)> is future, for some type R2, the function
returns future. Otherwise, the function returns future(const shared_future&)>>.
[ Note: This analogous to future. See the notes on the return type of future::then in 2.3. — end note ]
Postconditions: valid() == true on the original shared_future object. valid() == true on the future returned
from then.
11 bool is_ready() const;
Returns: true if the shared state is ready, otherwise false.
2.5 Class template promise [futures.promise]
The specifications of all declarations within this subclause 2.5 and its subclauses are the same as the corresponding
declarations, as specified in C++14 §30.6.5, unless explicitly specified otherwise.
The future returned by the function get_future is the one defined in the experimental namespace (2.3).
2.6 Class template packaged_task [futures.task]
The
...

Questions, Comments and Discussion

Ask us and Technical Secretary will try to provide an answer. You can facilitate discussion about the standard in here.

Loading comments...