E81 CSE 532S: Advanced Multi-Paradigm Software Development Chris Gill Department of Computer Science and Engineering Washington University in St. Louis.

Slides:



Advertisements
Similar presentations
E81 CSE 532S: Advanced Multi-Paradigm Software Development Chris Gill Department of Computer Science and Engineering Washington University in St. Louis.
Advertisements

CSE 332: C++ memory management idioms C++ Memory Management Idioms Idioms are reusable design techniques in a language –We’ll look at 4 important ones.
E81 CSE 532S: Advanced Multi-Paradigm Software Development Chris Gill Department of Computer Science and Engineering Washington University in St. Louis.
C++ Lecture 6 Object Life-times Creating objects using new Using pointers to objects Aggregation (Containment –UML speak) Other C++ class features.
CSE 332: C++ copy control I Copy Control (Part I) Copy control consists of 5 distinct operations –A copy constructor initializes an object by duplicating.
CSE 332: C++ copy control II Copy Control (Part II) Review: copy control consists of 5 distinct operations –A copy constructor initializes an object by.
What is UML? A modeling language standardized by the OMG (Object Management Group), and widely used in OO analysis and design A modeling language is a.
CSE 332: C++ templates and generic programming I Motivation for Generic Programming in C++ We’ve looked at procedural programming –Reuse of code by packaging.
E81 CSE 532S: Advanced Multi-Paradigm Software Development Chris Gill Department of Computer Science and Engineering Washington University, St. Louis
 2006 Pearson Education, Inc. All rights reserved Classes: A Deeper Look.
CSE 532: Midterm Review CSE 532 Fall 2013 Midterm Exam 80 minutes, during the usual lecture/studio time: 10:10am to 11:30am on Monday October 21, 2013.
CSE 425: Object-Oriented Programming II Implementation of OO Languages Efficient use of instructions and program storage –E.g., a C++ object is stored.
E81 CSE 532S: Advanced Multi-Paradigm Software Development Chris Gill Department of Computer Science Washington University, St. Louis
The Rest of the Story.  Constructors  Compiler-generated  The Initializer List  Copy Constructors  Single-arg (conversion ctors)  The Assignment.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 122 – Data Structures Classes: A Deeper Look Part.
CSE 332: C++ memory management idioms C++ Memory Management Idioms Idioms are reusable design techniques in a language –We’ll look at 4 important ones.
CSE 425: Object-Oriented Programming I Object-Oriented Programming A design method as well as a programming paradigm –For example, CRC cards, noun-verb.
111 © 2002, Cisco Systems, Inc. All rights reserved.
CSCI-383 Object-Oriented Programming & Design Lecture 14.
Proactor Pattern Venkita Subramonian & Christopher Gill
CS212: Object Oriented Analysis and Design Lecture 7: Arrays, Pointers and Dynamic Memory Allocation.
More about Class 靜宜大學資工系 蔡奇偉副教授 ©2011. 大綱 Instance Class Members Class members can be associated with an instance of the class or with the class as a.
E81 CSE 532S: Advanced Multi-Paradigm Software Development Chris Gill Department of Computer Science and Engineering Washington University in St. Louis.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 223 – Advanced Data Structures C++ Review Part-I.
CSE 432: Design Patterns Introduction What’s a Pattern? What’s an Idiom? According to Alexander, a pattern: –Describes a recurring problem –Describes the.
C++ Memory Overview 4 major memory segments Key differences from Java
The Big Three Based on Weiss “Data Structures and algorithm Analysis CS240 Computer Science II.
E81 CSE 532S: Advanced Multi-Paradigm Software Development Chris Gill Department of Computer Science and Engineering Washington University, St. Louis
Object-Oriented Programming in C++ More examples of Association.
Comp 248 Introduction to Programming Chapter 4 & 5 Defining Classes Part B Dr. Aiman Hanna Department of Computer Science & Software Engineering Concordia.
Writing Correct C++ Programs without “delete” Huang-Ming Huang CSE332 Guest Lecture Washington University in St. Louis.
CS212: Object Oriented Analysis and Design Lecture 20: Exception Handling-II.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 14: More About Classes.
E81 CSE 532S: Advanced Multi-Paradigm Software Development Venkita Subramonian, Christopher Gill, Ying Huang, Marc Sentany Department of Computer Science.
 2006 Pearson Education, Inc. All rights reserved Classes: A Deeper Look, Part 1.
How & When The Kernel Runs David Ferry, Chris Gill Department of Computer Science and Engineering Washington University, St. Louis MO
Chapter 17: Linked Lists. Objectives In this chapter, you will: – Learn about linked lists – Learn the basic properties of linked lists – Explore insertion.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 223 – Advanced Data Structures C++ Review 2.
CS162 - Topic #6 Lecture: Pointers and Dynamic Memory –Review –Dynamically allocating structures –Combining the notion of classes and pointers –Destructors.
E81 CSE 532S: Advanced Multi-Paradigm Software Development Chris Gill Department of Computer Science and Engineering Washington University in St. Louis.
Advanced BioPSE NCRR Programming Conventions and Standards J. Davison de St. Germain Chief Software Engineer SCI Institute December 2003 J.
PRINCIPLES OF OPERATING SYSTEMS Tutorial-4: Multi-process and Multi-threaded Programming CPSC 457, Spring 2015 May 28/29, 2015 Department of Computer Science,
Interrupts and Interrupt Handling David Ferry, Chris Gill CSE 522S - Advanced Operating Systems Washington University in St. Louis St. Louis, MO
CSE 532: Course Review CSE 532 Fall 2015 Final Exam 120 minutes, covering material throughout semester –1pm to 3pm on Wednesday December 16, 2015 –Arrive.
Processes David Ferry, Chris Gill CSE 522S - Advanced Operating Systems Washington University in St. Louis St. Louis, MO
C++11 Atomic Types and Memory Model
Introduction to Generic Programming in C++
Event Handling Patterns Asynchronous Completion Token
How & When The Kernel Runs
Programming with ANSI C ++
C++11 Threading Lieven de Cock
C++ Memory Management Idioms
Processes David Ferry, Chris Gill
Class: Special Topics Copy Constructors Static members Friends this
This pointer, Dynamic memory allocation, Constructors and Destructor
Inheritance Often, software encapsulates multiple concepts for which some attributes/behaviors overlap E.g. A computer (role-playing) game has: Monsters:
The Active Object Pattern
Overview of Memory Layout in C++
CSE 432 Presentation GoF: Factory Method PH: “To Kill a Singleton”
Half-Sync/Half-Async (HSHA) and Leader/Followers (LF) Patterns
Monitor Object Pattern
Testing and Debugging Concurrent Code
Strings and Pointer Arrays
COP 3330 Object-oriented Programming in C++
9-10 Classes: A Deeper Look.
C++ Constructor Insanity CSE 333 Summer 2018
Classes: A Deeper Look, Part 1
Class: Special Topics 2 For classes using memory allocation
Jim Fawcett CSE687 – Object Oriented Design Spring 2014
9-10 Classes: A Deeper Look.
Presentation transcript:

E81 CSE 532S: Advanced Multi-Paradigm Software Development Chris Gill Department of Computer Science and Engineering Washington University in St. Louis Managing C++11 Threads

Contruct a Thread to Launch It The std::thread constructor takes any callable type –A function, function pointer, function object, or lambda –This includes things like member function pointers, etc. –Additional constructor arguments passed to callable instance Watch out for argument passing semantics, though –Constructor arguments are copied locally without conversion –Need to wrap references in std::ref, force conversions, etc. Default construction (without a thread) also possible –Can transfer ownership of it via C++11 move semantics, i.e., using std::move from one std::thread object to another – Be careful not to move thread ownership to a std::thread object that already owns one (terminates the program)

Always Join With or Detach a Launched Thread Often you should join with each launched thread –E.g., to wait until a result it produces is ready to retrieve –E.g., to keep a resource it needs available for its lifetime However, for truly independent threads, can detach –Relinquishes parent thread’s option to rendezvous with it –Need to copy all resources into the thread up front –Avoids circular wait deadlocks (if A joins B and B joins A) Need to ensure join or detach for each thread –E.g., if an exception is thrown, still need to make it so –The guard (a.k.a. RAII) idiom helps with this, since guard’s destructor always joins or detaches if needed –The std::thread::joinable() method can be used to test that