1、BSI Standards Publication PD ISO/IEC TS 19571:2016 Programming Languages Technical Specification for C+ Extensions for ConcurrencyPD ISO/IEC TS 19571:2016 PUBLISHED DOCUMENT National foreword This Published Document is the UK implementation of ISO/IEC TS 19571:2016. The UK participation in its prepa
2、ration was entrusted to Technical Committee IST/5, Programming Languages. A list of organizations represented on this committee can be obtained on request to its secretary. This publication does not purport to include all the necessary provisions of a contract. Users are responsible for its correct
3、application. The British Standards Institution 2016. Published by BSI Standards Limited 2016 ISBN 978 0 580 90684 8 ICS 35.060 Compliance with a British Standard cannot confer immunity from legal obligations. This British Standard was published under the authority of the Standards Policy and Strateg
4、y Committee on 29 February 2016. Amendments/corrigenda issued since publication Date Text affectedPD ISO/IEC TS 19571:2016 Programming Languages Technical Specification for C+ Extensions for Concurrency Langages de programmation Spcification technique pour C + Extensions pour la concurrence ISO/IEC
5、TS 19571 First edition 2016-02-01 Reference number ISO/IEC TS 19571:2016(E) TECHNICAL SPECIFICATION ISO/IEC 2016 PD ISO/IEC TS 19571:2016ii ISO/IEC 2016 All rights reserved COPYRIGHT PROTECTED DOCUMENT ISO/IEC 2016, Published in Switzerland All rights reserved. Unless otherwise specified, no part of
6、 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 ISOs member body i
7、n 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 copyrightiso.org www.iso.org ISO/IEC TS 19571:2016(E)Contents Foreword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8、 . . . . . . . . . . . . . . . . . . . . . . . v 1 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.1 Namespaces, headers, and modifications to standard classes . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.2 Future p
9、lans (Informative) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1.3 Feature-testing recommendations (Informative) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 2 Improvements to std:future and Related APIs . . . . . . . . . . . . . . . .
10、 . . . . . . . . . . . . . . . . 3 2.1 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 2.2 Header synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 2.3 Class template future . . . . . . . . . . . . .
11、 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 2.4 Class template shared_future . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 2.5 Class template promise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
12、 8 2.6 Class template packaged_task . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 2.7 Function template when_all . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 2.8 Class template when_any_result . . . . . . . . . . . . . .
13、. . . . . . . . . . . . . . . . . . . . . . . . . 9 2.9 Function template when_any . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 2.10 Function template make_ready_future . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 2.11 Function templ
14、ate make_exceptional_future . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 3 Latches and Barriers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 3.1 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15、 . . . . . . . . . . . . . . . . 12 3.2 Terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 3.3 Latches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 3.4 Header synopsis . . . .
16、. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 3.5 Class latch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 3.6 Barrier types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
17、14 3.7 Header synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 3.8 Class barrier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 3.9 Class flex_barrier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
18、. . . . . . . . . . . . . . 15 4 Atomic Smart Pointers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 4.1 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 4.2 Header synopsis . . . . .
19、 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 4.3 Class template atomic_shared_ptr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 4.4 Class template atomic_weak_ptr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 ISO/IEC
20、201 6 All rights reserved iii PD ISO/IEC TS 19571:2016 ISO/IEC TS 19571:2016(E)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 I
21、SO 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
22、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 crit
23、eria 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 pate
24、nt 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 th
25、is 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 ISOs adherence to the WTO principles in the Technical Barriers
26、to Trade (TBT) see the following URL: Foreword - Supplementary information The committee responsible for this document is ISO/IEC JTC1. iv ISO/IEC 201 6 All rights reserved PD ISO/IEC TS 19571:2016 ISO/IEC TS 19571:2016(E)general 1 General general.namespaces 1.1 Namespaces, headers, and modification
27、s to standard classes 1 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: mod
28、ify 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
29、not the same as an existing subnamespace of namespace std. 2 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 3 Unless otherwise speci
30、fied, 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:. 4 Extensions that are expected to eventually be added to an exis
31、ting header are provided inside theheader, which shall include the standard contents of as if by #include 5 New headers are also provided in the directory, but without such an #include. Table 1 C+ library headersgeneral.plans 1.2 Future plans (Informative) 1 This section describes tentative plans fo
32、r future versions of this technical specification and plans for moving content into future versions of the C+ Standard. 2 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 vers
33、ion 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. 3 When an extension defined in this or a future version of this technical specificatio
34、n 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 headers path. ISO/IEC 201 6 All rights reserved 1 Programming Languages Technical Sp
35、ecification for C+ Extensions for Concurrency TECHNICAL SPECIFICATION ISO/IEC TS 19571:2016(E) PD ISO/IEC TS 19571:2016general.feature.test 1.3 Feature-testing recommendations (Informative) 1 For the sake of improved portability between partial implementations of various C+ standards, WG21 (the ISO
36、technical committee for the C+ programming language) recommends that implementers and programmers follow the guidelines in this section concerning feature-test macros. Note: WG21s SD-6 makes similar recommendations for the C+ Standard itself. end note 2 Implementers who provide a new standard featur
37、e 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
38、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. 3 Programmers who wish to determine whether a feature is available in an implementation should base tha
39、t 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
40、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. No. Title Primary Section Macro Name Suffix Value Header N4
41、399 Improvements to std:future and Related APIs 2 future_continuations 201505 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 201 6 All rights reserved PD ISO/IEC TS 19571:2016 ISO/IEC TS
42、 19571:2016(E)futures 2 Improvements to std:future and Related APIs futures.general 2.1 General 1 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:promis
43、e and std:packaged_task are also updated to be compatible with the updated std:future. header.future.synop 2.2 Header synopsis #include namespace std namespace experimental inline namespace concurrency_v1 template class promise; template class promise; template class future; template class shared_fu
44、ture; template class shared_future; template class shared_future; template class packaged_task; / undefined template class packaged_task; template void swap(packaged_task template see below make_ready_future(T future make_ready_future(); template future make_exceptional_future(exception_ptr ex); tem
45、plate future make_exceptional_future(E ex); template see below when_all(InputIterator first, InputIterator last); template ISO/IEC 201 6 All rights reserved 3 PD ISO/IEC TS 19571:2016 ISO/IEC TS 19571:2016(E)see below when_all(Futures template struct when_any_result; template see below when_any(Inpu
46、tIterator first, InputIterator last); template see below when_any(Futures / namespace concurrency_v1 / namespace experimental template struct uses_allocator, Alloc; template struct uses_allocator, Alloc; / namespace std futures.unique_future 2.3 Class template future 1 The specifications of all decl
47、arations 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(futur
48、e future(const future future(future future(); future future 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 4 ISO/IEC 201 6 All right
49、s reserved PD ISO/IEC TS 19571:2016 ISO/IEC TS 19571:2016(E)Effects: Postconditions: template future_status wait_until(const chrono:time_point / continuations template see below then(F ; / namespace concurrency_v1 / namespace experimental / namespace std 2 future(future 3 Constructs a future object from the shared state referred to by rhs. The future becomes ready when one of the
copyright@ 2008-2019 麦多课文库(www.mydoc123.com)网站版权所有
备案/许可证编号:苏ICP备17064731号-1