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.

THIS TRAINING COURSE WILL HELP YOU:

  • Understand C++ memory model for applications on multiple hardware threads
  • Learn synchronization tools for shared-memory data access
  • Understand coroutines and apply them in practical projects
  • Practice threads and coroutines using external libraries

WHO SHOULD ATTEND?

  • Software developers working on production projects
  • Programmers working with threads and coroutines
  • Engineers interested in multi-CPU programming
  • Developers who want to compare C++ with other environments

COURSE LOCATION AND AVAILABLE DATES



Public courses are usually delivered in Czech, but this course is also available in English. We can arrange private training for your team online, at your premises or in our classrooms, and tailor the content to your needs.

For groups of around 4 or more participants, private training can already be comparable in price to booking individual places on a public course. Send us your requirements and we’ll recommend the best format and provide an exact quote.

Request training in English

Course content:

Hide details
  • 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
Prerequisites:
Good knowledge of C++ programming.
Recommended previous course:
C++ – Practical Programming for Advanced Developers (CPP2)
Schedule:
4 days (9:00-17:00)

Training and learning environment