Skip to main content
Link
Menu
Expand
(external link)
Document
Search
Copy
Copied
Hamid Abbaszadeh
Multithreading
Overview
C++ Memory Model
Overview
Atomic Data Types
std::atomic_flag
std::atomic
std::atomic (Specializations)
Synchronization and Ordering Constraints
The Different C++ Memory Models
Sequential Consistency
Sequential Consistency – Theory
Sequential Consistency – Practice
Acquire-Release Semantic
Acquire-Release Semantic – Synchronization and Ordering Constraints
Acquire-Release Semantic – Transitivity
The Special Case std::memory_order_consume
The Typical Error
Relaxed Semantics
Wait and Sleep
Fences
Memory Barriers
Acquire- and Release Memory Barriers
Algorithms
Blocking and Non-Blocking Algorithms
ABA – A is not the same as A
The Threading Interface
Threads
Creation
Lifetime
Arguments
Sharing Data
Risks
Prefer Locks to Mutexes
Reader-Writer Locks
Safe Initialization
Thread-Local Data
Condition Variables
Tasks
std::async
std::packaged_task
std::promise and std::future
The Special Futures of std::async
Condition Variables versus Tasks for the Synchronization of Threads
Challenges
Data Races versus Race Conditions
Malicious Data Races
Blocking and Non-Blocking Algorithms (Revisited)
Multithreading with C++17 and C++20
An Overview
Parallel Algorithms of the Standard Template Library
Atomic Smart Pointers
std::future Extensions
Latches and Barriers
Coroutines
Transactional Memory
Task Blocks
Executors
Unified Futures
std::jthread
Application of Multithreading
The Time Library
Overview
Time Point
Time Duration
Clock
Wait and Sleep
Ongoing Optimization with CppMem
Context of Ongoing Optimization
Introduction to CppMem
Non-Atomic Variables
Locks
Sequential Consistency
Acquire-Release Semantic
Acquire-Release Semantic with a Data Race
Relaxed Semantic
volatile
Singleton
Thread-Safe Initialization of a Singleton
Calculating the Sum of a std::vector
Single-Threaded
Multithreaded with Shared Variables
Multithreaded with Minimal Synchronization
My Conclusion
The Dining Philosophers Problem
Dining Philosophers Problem I
Dining Philosophers Problem II
Dining Philosophers Problem III
Design Patterns and Architectural Patterns
A First Overview
Introduction
The Advantages of Patterns
The History of Patterns
Classification of Design Patterns
Classification of Patterns
Terminology
The Structure of Patterns
About Algorithms, Frameworks, and Pattern Relations
Anti-Patterns
Design Patterns
Creational Patterns
Factory Method
Slicing and Ownership Semantics
The Singleton
Pros and Cons
The Alternatives – The Monostate Pattern and Dependency Injection
Structural Patterns
The Adapter Pattern
The Bridge Pattern
The Decorator Pattern
The Composite Pattern
The Facade Pattern
The Proxy Pattern
Behavioral Patterns
The Visitor Pattern
The Template Method
The Strategy Pattern
Idioms
General
The Copy-and-Swap Idiom
Partial Function Application
Argument-Dependent Lookup and the Hidden Friend Idiom
Classes
The Rule of Zero or Six
Regular Types
Value Objects
The Null Object Pattern
The Iterator Protocol
Covariant Return Type
Polymorphism
Idioms for Polymorphism and Templates
Templates (Idioms)
Idioms for Polymorphism and Templates (Revisited)
Architectural Patterns
How Can You Recognize a Good Software Architecture? by Alexander Eisenhut
Layers
Pipes-and-Filters
Broker
Model-View-Controller
Reactor
Concurrency Patterns
Dealing with Sharing
Dealing with Mutation – Locking
Dealing with Mutation – The Thread-Safe Interface
Dealing with Mutation – Guarded Suspension
Active Object
Monitor Object
Thread-Safe Queue – Two Serious Errors
C++17
Core Language
More Details
Library
std::byte
std::filesystem
std::string_view
The New Algorithms of the STL
Improved Associative Containers and Uniform Container Access
Parallel Algorithms of the STL with the GCC Compiler
Performance of the Parallel STL Algorithms
C++ Parallel STL Benchmark by Victor J. Duvanenko
Polymorphic Allocators in C++17
Special Allocators with C++17
Optimization with Allocators in C++17
C++20
Overview
The Next Big Thing – C++20
The Big Four
Details
Concepts
Two Extremes and the Rescue with Concepts
The Details
The Placeholder Syntax
Syntactic Sugar
What We Don't Get
Predefined Concepts
Define Concepts
Define Concepts – Logical Combination of Other Concepts or Compile-Time Predicates
Defining Concepts with Requires Expressions
Using Requires Expressions in C++20 as a Standalone Feature
Define the Concepts Equal and Ordering
Define the Concepts Regular and SemiRegular
Check Types with Concepts – The Motivation
Check Types with Concepts
Concepts in C++20 – An Evolution or a Revolution?
Ranges Library
The Ranges Library
Functional Pattern with the Ranges Library
The Ranges Library in C++20 – More Details
Projections with Ranges
Sentinels and Concepts with Ranges Algorithms
Improved Iterators with Ranges
The Ranges Library in C++20 – Design Choices
The Ranges Library in C++20 – More Design Choices
Pythonic with the Ranges Library
Python's range Function – The Second
Python's map Function
Coroutines
A First Overview
More Details
An Infinite Data Stream with Coroutines
Thread Synchronization with Coroutines
cppcoro
Coroutines with cppcoro
Powerful Coroutines with cppcoro
Thread Pools with cppcoro
co_return
Implementing Simple Futures with Coroutines
Lazy Futures with Coroutines
Executing a Future in a Separate Thread
co_yield
A Generic Data Stream with Coroutines
co_await
Starting Jobs with Coroutines
Automatically Resuming a Job with Coroutines on a Separate Thread
A Concise Introduction to Coroutines by Dian-Lun Lin
Coroutines – A Scheduler for Tasks by Dian-Lun Lin
A Priority Scheduler for Coroutines
An Advanced Priority Scheduler for Coroutines
A Bug in the Priority Scheduler for Coroutines
A Coroutine-Based Single Consumer – Single Producer Workflow by Ljubic Damir
Modules
The Advantages of Modules
A Simple math Module
Module Interface Unit and Module Implementation Unit
Structure Modules
Open Questions to Modules
Private Module Fragment and Header Units
Module Support of the Big Three
More Details about Module Support of the Big Three
The Core Language (C++20)
The Three-Way Comparison Operator
More Details to the Spaceship Operator
Optimized Comparison with the Spaceship Operator
The Autogenerated Equality Operator
Designated Initializers
consteval and constinit
Solving the Static Initialization Order Fiasco
Various Template Improvements with C++20
More Powerful Lambdas with C++20
More Lambda Features with C++20
New Attributes with C++20
volatile and Other Small Improvements
The Library (C++20)
std::span – Bounds-Safe Views for Sequences of Objects
std::span – More Details
constexpr std::vector and std::string in C++20
More Convenience Functions for Containers with C++20
std::format – The Basics
Extend std::format for User-Defined Types
The Formatting Library in C++20
The Formatting Library in C++20 – The Format String
The Formatting Library in C++20 – The Format String (2)
Formatting User-Defined Types in C++20
More Details to Formatting User-Defined Types in C++20
Calendar and Time-Zone
Time of Day
Calendar Date
Handling Calendar Dates
Time-Zones
Basic Chrono Terminology
Basic Chrono Terminology with Time Duration and Time Point
Time of Day – Details
Creating Calendar Dates
Displaying and Checking Calendar Dates
Query Calendar Dates and Ordinal Dates
Time Zones – Details
Time Zones – Online Classes
Chrono I/O
Chrono I/O – Unformatted
Chrono – Input
Safe Comparison of Integrals
Feature Testing
Bit Manipulation
Atomics
Atomics – References
Synchronization with Atomics
Performance Comparison of Condition Variables and Atomics
Barriers and Atomic Smart Pointers
atomic
> by Oliver Schädlich
Semaphores
Latches
Barriers
Cooperative Interruption of a Thread
Cooperative Interruption of a Thread – Callbacks
std::jthread
Synchronized Output Streams
C++23
C++23: The Next C++ Standard
Core Language
Deducing This
Syntactic Sugar with Deducing This
The Small Pearls in the Core Language
More Small Pearls
Library
A Modularized Standard Library – std::print and std::println
Range Improvements with C++23
A New Way of Error Handling with std::expected
A Multidimensional View
Range Improvements and std::generator
C++26
C++26: The Next C++ Standard
Overview
An Overview of C++26 – Core Language
An Overview of C++26 – The Library
An Overview of C++26 – The Library – Math
An Overview of C++26 – Concurrency
Core Language
Reflection
Reflection in C++26 – Metafunctions
Reflection in C++26 – Metafunctions for Enums and Classes
Reflection in C++26 – Determine the Class Layout
Contracts in C++26
Contracts – A Deep Dive
Contracts – Evaluation Semantic
Placeholders and Extended Character Set
Small Safety Improvements in the C++26 Core Language
Library
string and string_view Processing
std::execution
std::execution – Asynchronous Algorithms
std::execution – Inclusive Scan
std::execution – Composition of Sender
std::execution – Sender
std::execution – More Sender
Deferred Reclamation in C++26 – RCU and Hazard Pointers
A Lock-Free Stack – A Simplified Implementation
A Lock-Free Stack – A Complete Implementation
A Lock-Free Stack – Atomic Smart Pointer
A Lock-Free Stack – A Simple Garbage Collector
A Lock-Free Stack – A Hazard Pointer Implementation
A Lock-Free Stack – A Hazard Pointer Implementation Explained I
A Lock-Free Stack – A Hazard Pointer Implementation Explained II
Hazard Pointers in C++26
Read-Copy-Update (RCU)
Data-Parallel Types (SIMD)
Data-Parallel Types – A First Example
Data-Parallel Types – simd_mask
Data-Parallel Types – Reduction
Data-Parallel Types – Algorithms
Templates
First Steps
Basics
Function Templates
More Details – Explicit Template Arguments and Concepts
Class Templates
Surprises Included – Inheritance and Member Functions of Class Templates
Alias Templates and Template Parameters
Template Arguments
Template Argument Deduction of Class Templates
Template Specialization
More Details about Class Templates
Full Specialization of Function Templates
Template Instantiation
Variadic Templates and Fold Expressions
Variadic Templates or the Power of Three Dots
More about Variadic Templates
From Variadic Templates to Fold Expressions
Smart Tricks with Parameter Packs and Fold Expressions
Visiting a std::variant with the Overload Pattern
The Special Friendship of Templates
Dependent Names
Techniques
Automatic Return Type (C++98)
Automatic Return Type (C++11/14/20)
Template Metaprogramming – How It All Started
Template Metaprogramming – How It Works
Hybrid Programming
Type Checks
Type Comparisons
std::is_base_of
Correctness
Performance
constexpr Functions
constexpr and consteval Functions in C++20
constexpr if
Design
Dynamic versus Static Polymorphism
CRTP
More about Dynamic versus Static Polymorphism
Mixins
Avoiding Temporaries with Expression Templates
Policy-Based Design
Traits and Tag Dispatching
A std::advance Implementation Based on C++98, C++11, and C++20
Type Erasure
Review
About
Search Hamid Abbaszadeh
C++26
Overview
Overview
Table of Contents
1. Overview
2. Details
1. Overview
TODO: write introduction for “Overview”.
2. Details
TODO: expand this section.
Table of contents
An Overview of C++26 – Core Language
An Overview of C++26 – The Library
An Overview of C++26 – The Library – Math
An Overview of C++26 – Concurrency