Damon's Blog
The magic you are looking for is in the work you're avoiding.
Gems
2026
January
9: What is the purpose of std::launder?
Money laundering is used to prevent people from tracing where you got your money from. Memory laundering is used to prevent the compiler from tracing where you got your object from, thus forcing it to avoid any optimizations that may no longer apply.
The placement new operator in C++ allows you to construct an object in a pre-allocated memory buffer.
7: std::jthread: A safer and more capable way of concurrency in C++20
The destructor of a std::thread object with an associated thread calls std::terminate if join() has not been called.
upper_bound: Returns the first iterator iter in [first, last) where bool(value < *iter) is true, or last if no such iter exists.
lower_bound: Returns the first iterator iter in [first, last) where bool(*iter < value) is false, or last if no such iter exists.
Compiling in debug mode will then include debug symbols (-g), disable optimisation (-00), and enable assert() by omitting -DNDEBUG.
在读操作占主导时,Wait-Free 表现极佳。因为读线程的“协助”行为分散了写线程的竞争压力,而且读操作本身不需要像 CAS 循环那样反复争抢缓存行。
但在写操作占主导时,Lock-Free 反而更快。为什么?因为 Wait-Free 的那些位运算、状态判断、原子交换握手,都是实打实的 CPU 指令开销。而 Lock-Free 在竞争不激烈的时候,就是一个简单的原子加减,极其轻量。
TODO
1: Transforming Uniform Random Variables to Normal
Central Limit Theorem (CLT) Method (12 Uniforms): Generate Gaussian samples by central limit theorem
Inverse Transform Sampling: How to generate Gaussian samples
Box-Muller Transform: Box-Muller
Beasley-Springer-Moro Algorithm
linear congruential generator
Transforming Uniform Random Variables to Normal
Box-Muller Transform
Beasley-Springer-Moro Algorithm
Inverse Transform Method
Contacts

Last updated