Revised Latches and Barriers for C++20

Size: px
Start display at page:

Download "Revised Latches and Barriers for C++20"

Transcription

1 Doc number: P0666R1 Revises: P0666R1, P0159R0, N4392 Date: Project: Programming Language C++, Concurrency Working Group Reply-to: Olivier Giroux Revised Latches and Barriers for C++20 Context This paper introduces changes to barrier objects that were requested at the Toronto 2017 meeting. These changes include: 1. Adding a split arrive/wait method interface, to enable overlapped computation. Note: though this was requested, the form in this proposal is new, exciting (!) and probably controversial. 2. A simplified concept of participating threads, which had feedback it was complicated & not useful. 3. Improved generic handling of barrier types, especially for barriers with completion phases. 4. Some latch class method names have changed, to clarify that their semantics have now become aligned with those of the barriers. Note: This was not requested, but the rationale used in the past was that the method names should differ because the semantics differed. Since this is no longer the case, it is proposed that they should match again. The previous revision of this paper proposed the unchanged section numbered 33.7 from P0159R0 (the Concurrency TS v1) for inclusion in the C++ standard. That proposal was not moved in Toronto C++ Proposed Wording Apply the following edits to N4713, the working draft of the Standard. The feature test macros cpp_lib_latch and cpp_lib_barrier should be created. Modify 33.1 General [thread.general] Table 140 Thread support library summary Subclause Header(s) 33.2 Requirements 33.3 Threads <thread> 33.4 Mutual exclusion <mutex> <shared_mutex> 33.5 Condition variables <condition_variable>

2 33.6 Futures <future> 33.7 Latches and barriers <latch> <barrier> 33.7 Latches and barriers [thread.coordination] 1 This section describes various concepts related to thread coordination, and defines the coordination type latch, basic_barrier and barrier. These types facilitate concurrent computation performed by a number of threads, in one or more phases. 2 In this subclause, a synchronization point represents a condition that a thread may wait for, potentially blocking until it is satisfied. A thread arrives at the synchronization point when it has an effect on the state of the condition, even if it does not cause it to become satisfied. The set of participating threads is the set of all threads that either arrive or wait at the synchronization point. 3 Each coordination type has an implementation-defined member class future_type that satisfies the requirements of MoveConstructible, MoveAssignable and Destructible, and meets the other requirements in this subclause. An instance of a future_type is associated with up to one synchronization point s condition, according to the effects of the member functions of the enclosing class. In this subclause, f denotes an instance of a future_type. 4 The expression f.wait() shall be well-formed and have the following semantics: Effects: If *this is associated with a synchronization point, blocks at the synchronization point until the condition to be satisfied. Otherwise, does not block. 5 Concurrent invocations of the member functions of coordination types, other than their destructors, and the member functions of their future_type do not introduce data races Latches [coordination.latch]: 6 A latch is a thread coordination mechanism that allows any number of threads to block until an expected count is summed (exactly) by threads that arrived at the latch. The expected count is set when the latch is constructed. An individual latch is a single-use object; once the count has been reached, the latch cannot be reused Header <latch> synopsis [latch.synopsis]: namespace std { class latch { public: explicit constexpr latch(ptrdiff_t expected); ~latch(); latch(const latch&) = delete; latch(latch&&) = delete; latch& operator=(const latch&) = delete; latch& operator=(latch&&) = delete; using future_type = implementation-defined; // see 33.7 bool try_wait() const noexcept; void arrive_and_wait(ptrdiff_t n = 1);

3 private: ptrdiff_t counter; // exposition only }; } // namespace std Class latch [latch.class]: 7 Class latch maintains an internal counter that is initialized when the latch is created. Threads may block at the latch s synchronization point, waiting for counter to be decremented to 0. explicit constexpr latch(ptrdiff_t expected); 8 Requires: expected >= 0. 9 Effects: counter = expected. 10 Remarks: Initializes the latch with the expected count. ~latch(); 11 Requires: No threads are blocked at the synchronization point. 12 Effects: Destroys the latch. 13 Remarks: May be called even if some threads have not yet returned from functions that block at the synchronization point, provided that they are unblocked. [ Note: The destructor may block until all threads have exited invocations of wait() on this object, or instances of future_type associated with this object. end note ] 14 Requires: counter >= update and update >= Effects: Constructs an object of type future_type that is associated with the latch s synchronization point and the condition counter == 0, then atomically decrements counter by update. 16 Synchronization: Synchronizes with the returns from all calls unblocked by the effects, and invocations of try_wait() on this latch that return true. 17 Returns: The constructed object. 18 Remarks: Arrives at the synchronization point with update count. bool try_wait() const noexcept; 19 Returns: counter == Effects: If counter == 0, returns immediately. Otherwise, blocks the calling thread at the synchronization point, until counter == 0. void arrive_and_wait(ptrdiff_t update); 21 Effects: Equivalent to: arrive(update); wait(); Barrier types [coordination.barrier]: 22 A barrier provides a thread-coordination mechanism that allows an expected number of threads to block until the same number of threads have arrived at the barrier. The expected number is set when the barrier is constructed, but may change according to some functions' effects. Unlike latches, barriers are reusable; once

4 threads are released from a barrier's synchronization point, they can reuse the same barrier immediately. [Note: It is thus useful for managing repeated tasks, or phases of a larger task, that are handled by multiple threads. end note.] 23 A barrier has a completion phase that is a (possibly empty) set of effects. When the member functions defined in this subclause arrive at the barrier, they have the following effects: 1. When the expected number of threads has arrived at the barrier, one of the participating threads executes the barrier type's completion phase. 2. When the completion phase is completed, all threads blocked at the synchronization point are unblocked. The end of the completion phase synchronizes with the returns from all calls unblocked by its completion Header <barrier> synopsis [barrier.synopsis]: namespace std { template<class Function> class basic_barrier; } using barrier = basic_barrier<implementation-defined>; Class basic_barrier [barrier.class]: template<class Function> class basic_barrier { public: explicit basic_barrier(ptrdiff_t expected, Function completion = Function()); ~basic_barrier(); basic_barrier(const basic_barrier&) = delete; basic_barrier(basic_barrier&&) = delete; basic_barrier& operator=(const basic_barrier&) = delete; basic_barrier& operator=(basic_barrier&&) = delete; using future_type = implementation-defined; // see 33.7 void arrive_and_wait(); void arrive_and_drop(); private: Function completion_; // exposition only }; 1 Template class basic_barrier is a barrier type with a completion phase controlled by a function object. The completion phase calls completion_(). 2 The template type argument Function shall be CopyConstructible, and instances of this type shall be Callable (C++14 [func.wrap.func]) with no arguments and return type void. explicit basic_barrier(ptrdiff_t expected, Function completion); 24 Requires: expected >= 0, and invoking completion shall not exit via an exception. 25 Effects: Initializes the barrier for expected number of threads, and initializes completion_ with std::move(completion). [ Note: If expected is 0 the set of participating threads will be empty, and consequently this object may only be destroyed. end note ]

5 ~basic_barrier(); 26 Requires: No threads are blocked at the synchronization point. 27 Effects: Destroys the barrier. 28 Remarks: May be called even if some threads have not yet returned from functions that block at the synchronization point, provided that they have unblocked. [ Note: The destructor may block until all threads have exited invocations of wait() on instances of future_type associated with this object. end note ] 29 Effects: Constructs an object of type future_type that is not associated with a synchronization point. 30 Returns: The constructed object. 31 Requires: The expected number of tasks is not Effects: Constructs an object of type future_type that is associated with the barrier s synchronization point and the condition that the expected number of threads arrive, then arrives at the synchronization point. 33 Synchronization: The call to arrive() synchronizes with the start of the completion phase. 34 Returns: The constructed object. 35 Remarks: This may cause the completion phase to start. void arrive_and_wait(); 36 Equivalent to: arrive().wait(). void arrive_and_drop(); 37 Requires: The expected number of tasks is not Effects: Decrements the expected number of threads by Synchronization: The call to arrive_and_drop() synchronizes with the start of the completion phase. 40 Remarks: This may cause the completion phase to start Barrier with predefined parameter [barrier.predef]: using barrier = basic_barrier<implementation-defined>; 3 The class barrier is a barrier type with an empty completion phase.

Apply the following edits to N4741, the working draft of the Standard. The feature test macros cpp_lib_latch and cpp_lib_barrier should be created.

Apply the following edits to N4741, the working draft of the Standard. The feature test macros cpp_lib_latch and cpp_lib_barrier should be created. Doc number: P0666R2 Revises: P0666R1, P0159R0, N4392 Date: 2018-05-06 Project: Programming Language C++, Concurrency Working Group Reply-to: Olivier Giroux Revised Latches and Barriers

More information

Efficient concurrent waiting for C++20

Efficient concurrent waiting for C++20 Doc number: P0514R3 Revises: P0514R2, P0126R2, N4195 Date: 2018-02-10 Project: Programming Language C++, Concurrency Working Group Reply-to: Olivier Giroux Efficient concurrent waiting

More information

Efficient waiting for concurrent programs

Efficient waiting for concurrent programs Doc number: P0514R2 Revises: P0514R0-1, P0126R0-2, and N4195 Date: 2017-10-09 Project: Programming Language C++, Concurrency Working Group Reply-to: Olivier Giroux Efficient waiting

More information

A jthread automatically signals an interrupt at the end of its lifetime to the started thread (if still joinable) and joins:

A jthread automatically signals an interrupt at the end of its lifetime to the started thread (if still joinable) and joins: Project: ISO JTC1/SC22/WG21: Programming Language C++ Doc No: WG21 Date: 2018-10-06 Reply to: Nicolai Josuttis (nico@josuttis.de), Herb Sutter (hsutter@microsoft.com), Anthony Williams (anthony@justsoftwaresolutions.co.uk)

More information

A Cooperatively Interruptible Joining Thread, Rev 4 New in R4

A Cooperatively Interruptible Joining Thread, Rev 4 New in R4 Project: ISO JTC1/SC22/WG21: Programming Language C++ Doc No: WG21 Date: 2018-09-11 Reply to: Nicolai Josuttis (nico@josuttis.de), Herb Sutter (hsutter@microsoft.com), Anthony Williams (anthony@justsoftwaresolutions.co.uk)

More information

Adding std::*_semaphore to the atomics clause.

Adding std::*_semaphore to the atomics clause. Doc number: P0514R1 Revises: P0514R0 Date: 2017-6-14 Project: Programming Language C++, Concurrency Working Group Reply-to: Olivier Giroux Adding std::*_semaphore to the atomics clause.

More information

Proposed Wording for Concurrent Data Structures: Hazard Pointer and Read Copy Update (RCU)

Proposed Wording for Concurrent Data Structures: Hazard Pointer and Read Copy Update (RCU) Document number: D0566R1 Date: 20170619 (pre Toronto) Project: Programming Language C++, WG21, SG1,SG14, LEWG, LWG Authors: Michael Wong, Maged M. Michael, Paul McKenney, Geoffrey Romer, Andrew Hunter

More information

Doc number: P0126R2 Revises: P0126R1, N4195 Date: Project: Reply-to: Thanks-to: A simplifying abstraction

Doc number: P0126R2 Revises: P0126R1, N4195 Date: Project: Reply-to: Thanks-to: A simplifying abstraction Doc number: P0126R2 Revises: P0126R1, N4195 Date: 2016-03-13 Project: Programming Language C++, Concurrency Working Group Reply-to: Olivier Giroux ogiroux@nvidia.com, Torvald Riegel triegel@redhat.com

More information

Interrupt Tokens and a Joining Thread, Rev 7 New in R7

Interrupt Tokens and a Joining Thread, Rev 7 New in R7 Project: ISO JTC1/SC22/WG21: Programming Language C++ Doc No: WG21 Date: 2018-11-049 Reply to: Nicolai Josuttis (nico@josuttis.de), Lewis Baker (lbaker@fb.com) Billy O Neal (bion@microsoft.com) Herb Sutter

More information

Proposed Wording for Concurrent Data Structures: Hazard Pointer and Read Copy Update (RCU)

Proposed Wording for Concurrent Data Structures: Hazard Pointer and Read Copy Update (RCU) Document number: P0566R5 Date: 20180506 (pre Rapperswil) Project: Programming Language C++, WG21, SG1,SG14, LEWG, LWG Authors: Michael Wong, Maged M. Michael, Paul McKenney, Geoffrey Romer, Andrew Hunter,

More information

Variant: a type-safe union without undefined behavior (v2).

Variant: a type-safe union without undefined behavior (v2). Variant: a type-safe union without undefined behavior (v2). P0087R0, ISO/IEC JTC1 SC22 WG21 Axel Naumann (axel@cern.ch), 2015-09-28 Contents Introduction 3 Version control 4 Discussion 4 Empty state and

More information

Enhancing std::atomic_flag for waiting.

Enhancing std::atomic_flag for waiting. Doc number: P0514R0 Revises: None. Date: 2016-11-15 Project: Programming Language C++, Concurrency Working Group Reply-to: Olivier Giroux Enhancing std::atomic_flag for waiting. TL;DR

More information

Structural Support for C++ Concurrency

Structural Support for C++ Concurrency Structural Support for C++ Concurrency Document number: P0642R0 Date: 2017-05-26 Project: Programming Language C++ Audience: SG1, SG8, EWG, LEWG Authors: Mingxin Wang (College of Software Engineering,

More information

async and ~future (Revision 3)

async and ~future (Revision 3) Doc No: WG21 N3637 Date: 2013-04-17 Reply to: Herb Sutter (hsutter@microsoft.com) Subgroup: SG1 Concurrency Previous Version: N3630 async and ~future (Revision 3) Herb Sutter, Chandler Carruth, Niklas

More information

Template Library for Parallel For Loops

Template Library for Parallel For Loops 1 Document number: P0075r2 Date: 2017-11-09 Audience: Reply to: Other authors: Concurrency study group (SG1) Pablo Halpern Clark Nelson Arch D. Robison,

More information

Fixing Atomic Initialization, Rev1

Fixing Atomic Initialization, Rev1 Project: ISO JTC1/SC22/WG21: Programming Language C++ Doc No: WG21 P0883R1 Date: 2018-06-05 Reply to: Nicolai Josuttis (nico@josuttis.de) Audience: SG1, LEWG, LWG Prev. Version: P0883R0 Fixing Atomic Initialization,

More information

Document Number: P0429R4 Date: Reply to: 0.1 Revisions... 1

Document Number: P0429R4 Date: Reply to: 0.1 Revisions... 1 Document Number: P0429R4 Date: 2018-05-05 Reply to: Zach Laine whatwasthataddress@gmail.com Audience: LWG A Standard flat_map Contents Contents i 0.1 Revisions.............................................

More information

Qualified std::function signatures

Qualified std::function signatures Document number: P0045R1 Date: 2017 02 06 To: SC22/WG21 LEWG Reply to: David Krauss (david_work at me dot com) Qualified std::function signatures std::function implements type-erasure of the behavior of

More information

Proposed Wording for Concurrent Data Structures: Read-Copy-Update (RCU)

Proposed Wording for Concurrent Data Structures: Read-Copy-Update (RCU) Document number: P1122R2 Date: 20181125 (post-san Diego) Project: Programming Language C++, WG21, LWG Authors: Paul McKenney, Michael Wong, Maged M. Michael, Geoffrey Romer, Andrew Hunter, Arthur O'Dwyer,

More information

A Cooperatively Interruptible Joining Thread, Rev 2

A Cooperatively Interruptible Joining Thread, Rev 2 Project: ISO JTC1/SC22/WG21: Programming Language C++ Doc No: WG21 P0660R3 Date: 2018-05-07 Reply to: Nicolai Josuttis (nico@josuttis.de), Herb Sutter (hsutter@microsoft.com), Anthony Williams (anthony@justsoftwaresolutions.co.uk)

More information

Proposed resolution for US104: Allocator-aware regular expressions (rev 4)

Proposed resolution for US104: Allocator-aware regular expressions (rev 4) Document number: P0269R0 Revision of: N4255 Date: 2016-02-14 Reply-to: mike_spertus@symantec.com Authors : Michael Spertus - mike_spertus@symantec.com John Maddock - boost.regex@virgin.net Audience: Library

More information

Hazard Pointers. Safe Resource Reclamation for Optimistic Concurrency

Hazard Pointers. Safe Resource Reclamation for Optimistic Concurrency Document Number: P0233R3 Date: 2017-02-06 Reply-to: maged.michael@acm.org, michael@codeplay.com Authors: Maged M. Michael, Michael Wong, Paul McKenney, Arthur O'Dwyer, David Hollman Project: Programming

More information

A polymorphic value-type for C++

A polymorphic value-type for C++ A polymorphic value-type for C++ ISO/IEC JTC1 SC22 WG21 Programming Language C++ P0201R2 Working Group: Library Evolution Date: 2017-10-16 Jonathan Coe Sean Parent

More information

A polymorphic value-type for C++

A polymorphic value-type for C++ A polymorphic value-type for C++ ISO/IEC JTC1 SC22 WG21 Programming Language C++ P0201R3 Working Group: Library Date: 2018-02-12 Jonathan Coe Sean Parent Change

More information

Variant: a typesafe union. ISO/IEC JTC1 SC22 WG21 N4218

Variant: a typesafe union. ISO/IEC JTC1 SC22 WG21 N4218 Variant: a typesafe union. ISO/IEC JTC1 SC22 WG21 N4218 Axel Naumann (axel@cern.ch) 2014-09-24 Contents Introduction 3 Discussion 4 A variant is not boost::any....................... 4 union versus variant...........................

More information

A polymorphic value type for C++

A polymorphic value type for C++ A polymorphic value type for C++ ISO/IEC JTC1 SC22 WG21 Programming Language C++ P0201R4 Working Group: Library Evolution, Library Date: 2018 10 05 Jonathan Coe Sean Parent

More information

Atomic maximum/minimum

Atomic maximum/minimum Atomic maximum/minimum Proposal to extend atomic with maximum/minimum operations Document number: P0493R0 Date: 2016-11-08 Authors: Al Grant (algrant@acm.org), Bronek Kozicki (brok@spamcop.net) Audience:

More information

p0052r6 - Generic Scope Guard and RAII Wrapper for the Standard Library

p0052r6 - Generic Scope Guard and RAII Wrapper for the Standard Library p0052r6 - Generic Scope Guard and RAII Wrapper for the Standard Library Peter Sommerlad and Andrew L. Sandoval with contributions by Eric Niebler and Daniel Krügler 2017-11-21 Document Number: p0052r6

More information

Working Draft, Technical Specification for C++ Extensions for Parallelism

Working Draft, Technical Specification for C++ Extensions for Parallelism Document Number: N3850 Date: 2014-01-17 Reply to: Jared Hoberock NVIDIA Corporation jhoberock@nvidia.com Working Draft, Technical Specification for C++ Extensions for Parallelism Note: this is an early

More information

More Improvements to std::future<t> - Revision 1

More Improvements to std::future<t> - Revision 1 Document number: N4048 Date: 2014-05-26 Revises: N3865 Project: JTC1.22.32 Programming Language C++ Reply to: Vicente J. Botet Escribá More Improvements to std::future - Revision

More information

Splicing Maps and Sets (Revision 1)

Splicing Maps and Sets (Revision 1) Document number: N3645 Date: 2013-05-04 Project: Programming Language C++ Reference: N3485 Reply to: Alan Talbot cpp@alantalbot.com Howard Hinnant howard.hinnant@gmail.com James Dennett jdennett@google.com

More information

National Body Comments ISO/IEC PDTS Technical Specification: C++ Extensions for Concurrency

National Body Comments ISO/IEC PDTS Technical Specification: C++ Extensions for Concurrency Document No: WG21 N4551 Date: 2015-08-13 References: ISO/IEC PDTS 19571 Reply To: Barry Hedquist INCITS/PL22.16 IR National Body Comments ISO/IEC PDTS 19571 Technical Specification: C++

More information

A polymorphic wrapper for all Callable objects (rev. 3)

A polymorphic wrapper for all Callable objects (rev. 3) Document number: P0288R1 Date: 2017 02 06 To: SC22/WG21 LEWG Reply to: David Krauss (david_work at me dot com) A polymorphic wrapper for all Callable objects (rev. 3) A new template unique_function is

More information

Variant: a type-safe union that is rarely invalid (v5).

Variant: a type-safe union that is rarely invalid (v5). Variant: a type-safe union that is rarely invalid (v5). P0088R0, ISO/IEC JTC1 SC22 WG21 Axel Naumann (axel@cern.ch), 2015-09-27 Contents Introduction 4 Results of the LEWG review in Urbana.................

More information

Working Draft, Technical Specification for C++ Extensions for Parallelism, Revision 1

Working Draft, Technical Specification for C++ Extensions for Parallelism, Revision 1 Document Number: N3960 Date: 2014-02-28 Reply to: Jared Hoberock NVIDIA Corporation jhoberock@nvidia.com Working Draft, Technical Specification for C++ Extensions for Parallelism, Revision 1 Note: this

More information

Controlling Thread Stack Size at Creation Time

Controlling Thread Stack Size at Creation Time Controlling Thread Stack Size at Creation Time Document #: Nxxxx Date: 2015-09-22 Revises: n/a Reply to: Patrice.Roy@USherbrooke.ca Contents Contents... 1 Background... 1 The Problem... 1 Benefits... 2

More information

Proposed resolution for US104: Allocator-aware regular expressions (rev 3)

Proposed resolution for US104: Allocator-aware regular expressions (rev 3) Document No: P1294R0 Revisions of: N3254=11-0024 Date: 2018-10-06 Authors : Michael Spertus - mike_spertus@symantec.com John Maddock - boost.regex@virgin.net Audience: LWG Proposed resolution for US104:

More information

p0407r2 - Allocator-aware basic_stringbuf

p0407r2 - Allocator-aware basic_stringbuf p0407r2 - Allocator-aware basic_stringbuf Peter Sommerlad 2017-11-16 Document Number: p0407r2 (referring to n3172 and LWG issue 2429) Date: 2017-11-16 Project: Programming Language C++ Audience: LWG/LEWG

More information

IBM Rational Rhapsody TestConductor Add On. Code Coverage Limitations

IBM Rational Rhapsody TestConductor Add On. Code Coverage Limitations IBM Rational Rhapsody TestConductor Add On Code Coverage Limitations 1 Rhapsody IBM Rational Rhapsody TestConductor Add On Code Coverage Limitations Release 2.7.1 2 License Agreement No part of this publication

More information

Multi-threaded Programming in C++

Multi-threaded Programming in C++ Multi-threaded Programming in C++ (2016/2017) Giuseppe Massari, Federico Terraneo giuseppe.massari@polimi.it federico.terraneo@polimi.it Outline 2/45 Introduction Multi-tasking implementations C++11 threading

More information

P0052R2 - Generic Scope Guard and RAII Wrapper for the Standard Library

P0052R2 - Generic Scope Guard and RAII Wrapper for the Standard Library P0052R2 - Generic Scope Guard and RAII Wrapper for the Standard Library Peter Sommerlad and Andrew L. Sandoval with contributions by Eric Niebler and Daniel Krügler 2016-03-18 Document Number: P0052R2

More information

p0052r5 - Generic Scope Guard and RAII Wrapper for the Standard Library

p0052r5 - Generic Scope Guard and RAII Wrapper for the Standard Library p0052r5 - Generic Scope Guard and RAII Wrapper for the Standard Library Peter Sommerlad and Andrew L. Sandoval with contributions by Eric Niebler and Daniel Krügler 2017-07-13 Document Number: p0052r5

More information

Orbix TS Thread Library Reference

Orbix TS Thread Library Reference Orbix 6.3.9 TS Thread Library Reference Micro Focus The Lawn 22-30 Old Bath Road Newbury, Berkshire RG14 1QN UK http://www.microfocus.com Copyright Micro Focus 2017. All rights reserved. MICRO FOCUS, the

More information

Working Draft, C++ Extensions for Networking

Working Draft, C++ Extensions for Networking Document Number: N4734 Date: 2018-04-04 Revises: N4711 Reply to: Jonathan Wakely cxx@kayari.org Working Draft, C++ Extensions for Networking Note: this is an early draft. It s known to be incomplet and

More information

Constraining unique_ptr

Constraining unique_ptr Constraining unique_ptr Document: N2853=09-0043 Date: 2009-03-20 Reply to: Alisdair Meredith public@alisdairm.net Introduction Unique_ptr is a new class template introduced in C++0x to simplify the use

More information

Design Patterns in C++

Design Patterns in C++ Design Patterns in C++ Concurrency Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa May 2, 2011 G. Lipari (Scuola Superiore Sant Anna) Concurrency May 2, 2011 1 / 34 Outline

More information

Concepts for the C++0x Standard Library: Iterators (Revision 2)

Concepts for the C++0x Standard Library: Iterators (Revision 2) Concepts for the C++0x Standard Library: Iterators (Revision 2) Douglas Gregor, Jeremy Siek and Andrew Lumsdaine Open Systems Laboratory Indiana University Bloomington, IN 47405 dgregor@osl.iu.edu, siek@colorado.edu,

More information

A Proposal for the World s Dumbest Smart Pointer, v2

A Proposal for the World s Dumbest Smart Pointer, v2 A Proposal for the World s Dumbest Smart Pointer, v2 Document #: WG21 N3740 Date: 2013-08-30 Revises: N3514 Project: JTC1.22.32 Programming Language C++ Reply to: Walter E. Brown

More information

Operator Dot Wording

Operator Dot Wording 2016-10-16 Operator Dot Wording Bjarne Stroustrup (bs@ms.com) Gabriel Dos Reis (gdr@microsoft.com) Abstract This is the proposed wording for allowing a user-defined operator dot (operator.()) for specifying

More information

Supporting async use-cases for interrupt_token

Supporting async use-cases for interrupt_token Document No. P1287R0 Date 2018-10-08 Reply To Audience Lewis Baker < lbaker@fb.com > Kirk Shoop < kirkshoop@fb.com > SG1, LEWG Supporting async use-cases for interrupt_token Abstract The jthread paper

More information

TS Thread Library Reference. Version 6.2, December 2004

TS Thread Library Reference. Version 6.2, December 2004 TS Thread Library Reference Version 6.2, December 2004 IONA, IONA Technologies, the IONA logo, Orbix, Orbix/E, Orbacus, Artix, Orchestrator, Mobile Orchestrator, Enterprise Integrator, Adaptive Runtime

More information

Week 3. Locks & Semaphores

Week 3. Locks & Semaphores Week 3 Locks & Semaphores Synchronization Mechanisms Locks Very primitive constructs with minimal semantics Semaphores A generalization of locks Easy to understand, hard to program with Condition Variables

More information

Responses to National Body Comments for ISO/IEC PDTS 19750, C++ Extensions for Parallelism Version 2

Responses to National Body Comments for ISO/IEC PDTS 19750, C++ Extensions for Parallelism Version 2 Document No: SC22/WG21 N4752 Date: 2018-06-08 Project: Programming Languages C++ Extensions for Parallelism Version 2 References: Reply to: Bryce Adelstein Lelbach Responses to

More information

Summary. Design. Layout

Summary. Design. Layout Flat containers wording Document number: P0460R0 Date: 2016-10-15 Reply-to: Sean Middleditch sean@middleditch.us Project: ISO JTC1/SC22/WG21: Programming Language C++ Audience: Library Evolution Working

More information

Processes and Threads. Industrial Programming. Processes and Threads (cont'd) Processes and Threads (cont'd)

Processes and Threads. Industrial Programming. Processes and Threads (cont'd) Processes and Threads (cont'd) Processes and Threads Industrial Programming Lecture 5: C# Threading Introduction, Accessing Shared Resources Based on: An Introduction to programming with C# Threads By Andrew Birrell, Microsoft, 2005

More information

Hazard Pointers. Safe Resource Reclamation for Optimistic Concurrency

Hazard Pointers. Safe Resource Reclamation for Optimistic Concurrency Document Number: P0233R1 Date: 2016 05 29 Reply to: maged.michael@acm.org, michael@codeplay.com Authors: Maged M. Michael, Michael Wong Project: Programming Language C++, SG14/SG1 Concurrency, LEWG Hazard

More information

p0052r7 - Generic Scope Guard and RAII Wrapper for the Standard Library

p0052r7 - Generic Scope Guard and RAII Wrapper for the Standard Library p0052r7 - Generic Scope Guard and RAII Wrapper for the Standard Library Peter Sommerlad and Andrew L. Sandoval with contributions by Eric Niebler and Daniel Krügler 2018-03-26 Document Number: p0052r7

More information

Working Draft, Extensions to C++ for Modules

Working Draft, Extensions to C++ for Modules Document Number: Date: 2017-02-03 Revises: N4610 Reply to: Gabriel Dos Reis Microsoft gdr@microsoft.com Working Draft, Extensions to C++ for Modules Note: this is an early draft. It s known to be incomplet

More information

3.Constructors and Destructors. Develop cpp program to implement constructor and destructor.

3.Constructors and Destructors. Develop cpp program to implement constructor and destructor. 3.Constructors and Destructors Develop cpp program to implement constructor and destructor. Constructors A constructor is a special member function whose task is to initialize the objects of its class.

More information

IT 540 Operating Systems ECE519 Advanced Operating Systems

IT 540 Operating Systems ECE519 Advanced Operating Systems IT 540 Operating Systems ECE519 Advanced Operating Systems Prof. Dr. Hasan Hüseyin BALIK (5 th Week) (Advanced) Operating Systems 5. Concurrency: Mutual Exclusion and Synchronization 5. Outline Principles

More information

Object-Oriented Programming for Scientific Computing

Object-Oriented Programming for Scientific Computing Object-Oriented Programming for Scientific Computing Smart Pointers and Constness Ole Klein Interdisciplinary Center for Scientific Computing Heidelberg University ole.klein@iwr.uni-heidelberg.de Summer

More information

RCU and C++ Paul E. McKenney, IBM Distinguished Engineer, Linux Technology Center Member, IBM Academy of Technology CPPCON, September 23, 2016

RCU and C++ Paul E. McKenney, IBM Distinguished Engineer, Linux Technology Center Member, IBM Academy of Technology CPPCON, September 23, 2016 Paul E. McKenney, IBM Distinguished Engineer, Linux Technology Center Member, IBM Academy of Technology CPPCON, September 23, 2016 RCU and C++ What Is RCU, Really? Publishing of new data: rcu_assign_pointer()

More information

Range Adaptors and Utilities

Range Adaptors and Utilities Document Number: Date: 2017-11-17 Reply to: Eric Niebler eric.niebler@gmail.com Range Adaptors and Utilities Note: this is an early draft. It s known to be incomplet and incorrekt, and it has lots of bad

More information

Proposed resolution for US104: Allocator-aware regular expressions (rev 3)

Proposed resolution for US104: Allocator-aware regular expressions (rev 3) N4255 Revision of: N3254 Date: 2014-11-03 Authors : Michael Spertus - mike_spertus@symantec.com John Maddock - boost.regex@virgin.net Proposed resolution for US104: Allocator-aware regular expressions

More information

A Standard flat_set. This paper outlines what a (mostly) API-compatible, non-node-based set might look like.

A Standard flat_set. This paper outlines what a (mostly) API-compatible, non-node-based set might look like. A Standard flat_set Document Number: P1222R0 Date: 2018-10-02 Reply to: Zach Laine whatwasthataddress@gmail.com Audience: LEWG 1 Introduction This paper outlines what a (mostly) API-compatible, non-node-based

More information

Systems Programming & Scripting

Systems Programming & Scripting Systems Programming & Scripting Lecture 10: C# Threading Introduction, Accessing Shared Resources Based on: An Introduction to programming with C# Threads By Andrew Birrell, Microsoft, 2005 Examples from

More information

Variant: a type-safe union (v3).

Variant: a type-safe union (v3). Variant: a type-safe union (v3). N4516, ISO/IEC JTC1 SC22 WG21 Axel Naumann (axel@cern.ch), 2015-05-06 Contents Introduction 4 Version control 5 Results of the LEWG review in Urbana................. 5

More information

High Performance Computing Course Notes Shared Memory Parallel Programming

High Performance Computing Course Notes Shared Memory Parallel Programming High Performance Computing Course Notes 2009-2010 2010 Shared Memory Parallel Programming Techniques Multiprocessing User space multithreading Operating system-supported (or kernel) multithreading Distributed

More information

CSCE 110 PROGRAMMING FUNDAMENTALS

CSCE 110 PROGRAMMING FUNDAMENTALS CSCE 110 PROGRAMMING FUNDAMENTALS WITH C++ Prof. Amr Goneid AUC Part 15. Dictionaries (1): A Key Table Class Prof. amr Goneid, AUC 1 Dictionaries(1): A Key Table Class Prof. Amr Goneid, AUC 2 A Key Table

More information

Iterator Concepts for the C++0x Standard Library

Iterator Concepts for the C++0x Standard Library Iterator Concepts for the C++0x Standard Library Douglas Gregor, Jeremy Siek and Andrew Lumsdaine dgregor@osl.iu.edu, jeremy.siek@colorado.edu, lums@osl.iu.edu Document number: N2500=08-0010 Revises document

More information

Object-Oriented Principles and Practice / C++

Object-Oriented Principles and Practice / C++ Object-Oriented Principles and Practice / C++ Alice E. Fischer October 10, 2016 OOPP / C++ Lecture 7... 1/15 Construction and Destruction Kinds of Constructors Move Semantics OOPP / C++ Lecture 7... 2/15

More information

[[nodiscard]] in the Library, Rev1

[[nodiscard]] in the Library, Rev1 Project: ISO JTC1/SC22/WG21: Programming Language C++ Doc No: WG21 P0600R1 Date: 2017-11-09 Reply to: Nicolai Josuttis (nico@josuttis.de) Audience: LEWG, LWG Prev. Version: P0600R0 [[nodiscard]] in the

More information

Programming Languages Technical Specification for C++ Extensions for Parallelism

Programming Languages Technical Specification for C++ Extensions for Parallelism ISO 05 All rights reserved ISO/IEC JTC SC WG N4409 Date: 05-04-0 ISO/IEC DTS 9570 ISO/IEC JTC SC Secretariat: ANSI Programming Languages Technical Specification for C++ Extensions for Parallelism Warning

More information

A Standard flat_map. 1 Revisions. 2 Introduction. 3 Motivation and Scope. 1.1 Changes from R Changes from R0

A Standard flat_map. 1 Revisions. 2 Introduction. 3 Motivation and Scope. 1.1 Changes from R Changes from R0 A Standard flat_map Document Number: P0429R2 Date: 2016-08-31 Reply to: Zach Laine whatwasthataddress@gmail.com Audience: LWG/LEWG 1 Revisions 1.1 Changes from R1 Add deduction guides. Change value_type

More information

Layout-compatibility and Pointer-interconvertibility Traits

Layout-compatibility and Pointer-interconvertibility Traits Document: P0466R2 Date: 2018-03-29 Reply-to: Lisa Lippincott Audience: Evolution; LEWG; LWG Layout-compatibility and Pointer-interconvertibility Traits Lisa Lippincott Abstract

More information

P0052R4 - Generic Scope Guard and RAII Wrapper for the Standard Library

P0052R4 - Generic Scope Guard and RAII Wrapper for the Standard Library P0052R4 - Generic Scope Guard and RAII Wrapper for the Standard Library Peter Sommerlad and Andrew L. Sandoval with contributions by Eric Niebler and Daniel Krügler 2017-06-15 Document Number: P0052R4

More information

Concepts for the C++0x Standard Library: Iterators

Concepts for the C++0x Standard Library: Iterators Concepts for the C++0x Standard Library: Iterators Douglas Gregor, Jeremiah Willcock, and Andrew Lumsdaine Open Systems Laboratory Indiana University Bloomington, IN 47405 {dgregor, jewillco, lums@cs.indiana.edu

More information

ENGR 3950U / CSCI 3020U UOIT, Fall 2012 Quiz on Process Synchronization SOLUTIONS

ENGR 3950U / CSCI 3020U UOIT, Fall 2012 Quiz on Process Synchronization SOLUTIONS Name: Student Number: SOLUTIONS ENGR 3950U / CSCI 3020U (Operating Systems) Quiz on Process Synchronization November 13, 2012, Duration: 40 Minutes (10 questions and 8 pages, 45 Marks) Instructor: Dr.

More information

Source-Code Information Capture

Source-Code Information Capture Source-Code Information Capture Robert Douglas 2015-04-08 Document Number: N4417 followup to N4129 Date: 2015-04-08 Project: Programming Language C++ 1 Introduction Logging, testing, and invariant checking

More information

Unified concept definition syntax

Unified concept definition syntax Document number P0716R0 Date 2017-06-19 Authors Richard Smith < richard@metafoo.co.uk > Andrew Sutton < asutton@uakron.edu > Audience Evolution Unified concept definition syntax Introduction At Kona, P0324R0

More information

Faculty of Information and Communication Technologies

Faculty of Information and Communication Technologies Swinburne University Of Technology Faculty of Information and Communication Technologies ASSIGNMENT COVER SHEET Subject Code: Subject Title: Assignment number and title: Due date: Lecturer: HIT3303 Data

More information

C++ Basics. Data Processing Course, I. Hrivnacova, IPN Orsay

C++ Basics. Data Processing Course, I. Hrivnacova, IPN Orsay C++ Basics Data Processing Course, I. Hrivnacova, IPN Orsay The First Program Comments Function main() Input and Output Namespaces Variables Fundamental Types Operators Control constructs 1 C++ Programming

More information

Coroutine concepts and metafunctions

Coroutine concepts and metafunctions Document No. P1288R0 Date 2018-10-07 Reply To Audience Lewis Baker SG1, LEWG Coroutine concepts and metafunctions Abstract The Coroutines TS introduces the ability to co_await a value from

More information

Proposed Resolution to TR1 Issues 3.12, 3.14, and 3.15

Proposed Resolution to TR1 Issues 3.12, 3.14, and 3.15 Document Number: N1713=04-0153 Date: October 20, 2004 Reply to: Pete Becker Dinkumware, Ltd. petebecker@acm.org Proposed Resolution to TR1 Issues 3.12, 3.14, and 3.15 This paper proposes a resolution to

More information

Synchronization Spinlocks - Semaphores

Synchronization Spinlocks - Semaphores CS 4410 Operating Systems Synchronization Spinlocks - Semaphores Summer 2013 Cornell University 1 Today How can I synchronize the execution of multiple threads of the same process? Example Race condition

More information

Implicit Evaluation of auto Variables and Arguments

Implicit Evaluation of auto Variables and Arguments Implicit Evaluation of auto Variables and Arguments Document number: N4035 (update of N3748) Authors: Joël Falcou University Paris XI, LRI Peter Gottschling SimuNova Herb Sutter Microsoft Date: 2013-08-30

More information

std::optional from Scratch

std::optional from Scratch std::optional from Scratch https://wg21.link/n4606 http://en.cppreference.com/w/cpp/utility/optional http://codereview.stackexchange.com/questions/127498/an-optionalt-implementation An optional object

More information

Shared Objects & Mutual Exclusion

Shared Objects & Mutual Exclusion Feb. 08, 2012 Concurrent Execution Concepts Process interference Mutual exclusion Models Model checking for interference Modeling mutual exclusion Practice Multithreaded Java programs Thread interference

More information

Concurrent programming in C++11

Concurrent programming in C++11 Concurrent programming in C++11 Computer Architecture J. Daniel García Sánchez (coordinator) David Expósito Singh Francisco Javier García Blas ARCOS Group Computer Science and Engineering Department University

More information

DPHPC: Introduction to OpenMP Recitation session

DPHPC: Introduction to OpenMP Recitation session SALVATORE DI GIROLAMO DPHPC: Introduction to OpenMP Recitation session Based on http://openmp.org/mp-documents/intro_to_openmp_mattson.pdf OpenMP An Introduction What is it? A set

More information

Object-Oriented Principles and Practice / C++

Object-Oriented Principles and Practice / C++ Object-Oriented Principles and Practice / C++ Alice E. Fischer May 13, 2013 OOPP / C++ Lecture 7... 1/27 Construction and Destruction Allocation and Deallocation Move Semantics Template Classes Example:

More information

Making std::vector constexpr

Making std::vector constexpr Making std::vector constexpr Document #: P1004R0 Date: 2018-04-01 Project: Programming Language C++ Audience: LEWG Reply-to: Louis Dionne 1 Abstract std::vector is not currently constexpr

More information

C++ State Template Class Library STTCL Concept. Version 2.0 / Mar 17, 2013 Author: Günther Makulik

C++ State Template Class Library STTCL Concept. Version 2.0 / Mar 17, 2013 Author: Günther Makulik C++ State Template Class Library Version 2.0 / Mar 17, 2013 Author: Günther Makulik (g-makulik@t-online.de) Table of Contents 1 Overview...4 1.1 The GoF State pattern...4 1.2 Mapping UML State Machine

More information

Feedback on P0214R5. Document Number P0820R0. Date Tim Shen < >

Feedback on P0214R5. Document Number P0820R0. Date Tim Shen < > Feedback on P0214R5 Document Number P0820R0 Date 2017-10-13 Reply-to Audience Tim Shen < timshen91@gmail.com > SG1, LEWG Abstract We investigated some of our SIMD applications and have some feedback on

More information

A Parallel Algorithms Library N3724

A Parallel Algorithms Library N3724 A Parallel Algorithms Library N3724 Jared Hoberock Jaydeep Marathe Michael Garland Olivier Giroux Vinod Grover {jhoberock, jmarathe, mgarland, ogiroux, vgrover}@nvidia.com Artur Laksberg Herb Sutter {arturl,

More information

A Unit Type for C++ Introduction. Related proposals. Proposed changes

A Unit Type for C++ Introduction. Related proposals. Proposed changes A Unit Type for C++ Document number: P1014R0 Date: April 1, 2018 Audience: Reply-to: Introduction EWG Andrew Sutton Nevin Liber Many languages, especially

More information

Object-Oriented Programming for Scientific Computing

Object-Oriented Programming for Scientific Computing Object-Oriented Programming for Scientific Computing Dynamic Memory Management Ole Klein Interdisciplinary Center for Scientific Computing Heidelberg University ole.klein@iwr.uni-heidelberg.de 2. Mai 2017

More information

Distributed Real-Time Control Systems. Lecture 17 C++ Programming Intro to C++ Objects and Classes

Distributed Real-Time Control Systems. Lecture 17 C++ Programming Intro to C++ Objects and Classes Distributed Real-Time Control Systems Lecture 17 C++ Programming Intro to C++ Objects and Classes 1 Bibliography Classical References Covers C++ 11 2 What is C++? A computer language with object oriented

More information

p0448r1 - A strstream replacement using span<chart> as buffer

p0448r1 - A strstream replacement using span<chart> as buffer p0448r1 - A strstream replacement using span as buffer Peter Sommerlad 2017-06-07 Document Number: p0448r1 (N2065 done right?) Date: 2017-06-07 Project: Programming Language C++ Audience: LWG/LEWG

More information

A Proposal for the World s Dumbest Smart Pointer

A Proposal for the World s Dumbest Smart Pointer A Proposal for the World s Dumbest Smart Pointer Document #: WG21/N3514 Date: 2012-12-19 Revises: None Project: Programming Language C++ Reply to: Walter E. Brown Contents 1 Introduction

More information