C++ – Threads, Coroutines and Asynchronous I/O (CPP4)

Programming, C, C++

Since C++11 the standard adds support for OS threads, a model for multithreaded programs and basic synchronization. This lets you build portable code with parallel computation, concurrent I/O and reliable synchronization across different platforms.

From C++20 the standard library adds many synchronization utilities and native coroutines, enabling lightweight cooperative tasks. C++26 adds tools for lock-free algorithms and data structures. The course covers Boost.Asio where needed.

Location, current course term

Contact us

Custom Customized Training (date, location, content, duration)

The course:

Hide detail
  • Parallel programming in C++
    1. Multithreading and multiprocessing
    2. Coroutines and in-process scheduling
    3. Synchronizing access to resources
  • Multithreaded data model
    1. What can go wrong (undefined behavior)
    2. When the language actually guarantees behavior
    3. How to write correct parallel programs
  • Working with threads in C++
    1. Starting and stopping threads
    2. Waiting for thread completion
    3. Main-thread termination and destructors
  • Classic thread synchronization
    1. Locking shared data (mutex)
    2. Notification via condition variables
    3. Mutex performance in operating systems
  • Advanced synchronization tools
    1. Signaling with semaphores
    2. Other utilities (barrier, latch)
  • Futures and asynchronous execution
    1. Object representing a future value (future)
    2. Producer-side promise (promise)
    3. Running functions in background threads (std::async)
  • Atomic variables and operations
    1. Visibility of memory changes
    2. Hardware and operation ordering (memory order)
    3. Atomic ops and correct programs
  • Lock-free data structures
    1. Using atomic operations (CAS)
    2. Algorithmic properties (lock-free, wait-free)
    3. The ABA problem
  • From custom implementations to C++26 and beyond
    1. Data-structure updates via copy methods (RCU)
    2. Support for pointer tagging (hazard pointers)
    3. Bonus: transactional memory
  • Practical thread applications
    1. Communication over TCP/IP
    2. Applications on top of HTTP
    3. Using existing thread pools
  • Asynchronous calls via callbacks
    1. Scheduling actions with callbacks
    2. Typed action objects (lambdas, captures)
    3. The senders/receivers concept
  • Coroutines and asynchronous I/O
    1. Motivation for using coroutines
    2. External libraries with schedulers
    3. Possible impacts in embedded systems
  • Principles of asynchronous I/O
    1. Integrating scheduler and I/O
    2. Computation versus communication
    3. Interaction with multithreading
  • Asynchronous network communication
    1. TCP/IP communication
    2. HTTP server and client
    3. Concurrency with other operations
  • Embedded systems and hardware I/O
    1. Serial line communication
    2. Local communication channels
    3. OS interaction
  • Compute threads and coroutines
    1. Coroutines focused on I/O work
    2. CPU-bound versus I/O-bound tasks
    3. Combining threads and coroutines
Assumed knowledge:
Good knowledge of C++ programming.
Recommended previous course:
C++ – Practical Programming for Advanced Developers (CPP2)
Schedule:
4 days (9:00 AM - 5:00 PM )
Language:

Vybrané zákaznické reference

ERA a.s., Libor M.
C++ – Threads, Coroutines and Asynchronous I/O ( CPP4)
"Kurz splnil má očekávání. Srozumitelný a jasný výklad probírané problematiky s odkazem na praxi."
ERA a.s., Vladimír N.
C++ – Threads, Coroutines and Asynchronous I/O ( CPP4)
"Vzhledem k obtížnosti a šíři tématu se lektor velice profesionálně orientoval, srovnání s jinými programovacími jazyky."