Rico's Nerd Cluster

「离开世界之前 一切都是过程」

C++ - [Concurrency 6] Memory Model

Introduction The C++ memory model was formally introduced in C++11 mainly for multithreading. Before C++11: Threading was platform-dependent. (POSIX threads for Unit systems) Behavior of sh...

C++ - [Concurrency 5] Coroutine

Coroutine Coroutines in C++ allows us to write asynchronous code in a sequential style. It allows us to resume and suspend, instead of blocking a thread. A coroutine by default is single-threaded,...

C++ - [Concurrency 4] Various Concurrent Methods

Asynchonous Programming, Vectorization, `std::launch`, Lockless array writes, OpenMP, SIMD, SSE2

Asynchronous Programming Single-Threaded Asynchornous Programming Cooperative Multitasking & Pre-emptive Multitasking This is a model where each task voluntari...

C++ - [Concurrency 3] Promise, Future, Packaged_Tasks

promise <> future; packaged_tasks

C++ - [Concurrency 2] Conditional Variables, Jthread

Conditional Variables, Jthread

Conditional Variables Vanilla Usage 1 2 3 4 5 std::unique_lock<std::mutex> lock(mutex_); cv_.wait(lock, pred); do_stuff_1(); do_stuff_2(); What actually happens std::unique_lock lock...

C++ - [Concurrency 10] Mutable Variables

Mutable Variable In this example, we are able to change a mutable variable in a const function 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 #include <iostream> #include...

C++ - [Concurrency 9] Scoped Lock and `adopt_lock`

adopt_lock In a bank transfer system, if we transfer A->B and B->A concurrently. std::lock() locks two locks in a dead-lock free way, but does not unlock automatically, so we need to unlock ...

C++ - [Concurrency 8] `std::this_thread::yield()`

Introduction std::this_thread::yield() is used in a case where you are busy waiting and fighting for CPU time slices. It will give the scheduler a hint that other threads could come in and finsih ...

Threading Motivation: Why C++ Concurrency Matters Standardized concurrency arrived with C++11, replacing the ad-hoc C / compiler-specific APIs used before C++98 with a formal memory model. Key l...

Docker Compose Profile

Multi-Container Workflow

Simple Example On Docker Profile Profiles help you adjust your Compose application for different environments or use cases by selectively activating services. Services can be assigned to one or mo...