Skip to content

Latest commit

 

History

History
45 lines (36 loc) · 1.96 KB

README.md

File metadata and controls

45 lines (36 loc) · 1.96 KB

Modern C++ concurrency lib minimum tutorial

This is the road that I learn about c++ concurrency. There may be some mistakes, you can contact me through email([email protected]) or issue.

Intro

Modern C++ includes built-in support for:

It's confuse when you see these classes, and I will write this note to record my learning process.
(This is a simple tutorial for modern c++ beginner.)

Thread is the base of concurrency. Threads allow multiple functions to execute concurrently.

You know something about POSIX lock API such as pthread_mutex_init(), pthread_mutex_lock(), pthread_mutex_unlock().
The class std::mutex encapsulate pthread lock lib.

The class std::lock_guard is a mutex wrapper that provides a convenient RAII-style mechanism for owning a mutex for the duration of a scoped block.

The use of std::unique_lock is similar to std::mutex.

A condition variable is an object able to block the calling thread until notified to resume.

Here is something you need to transfer value between threads.

Reference