Skip to content

Commit adf5f83

Browse files
behnamasadiclaude
andcommitted
Restructure pointer/threading docs and add lock-free DS reference
Multithreading doc rewritten with numbered headings (1, 1.1, ...), runnable examples, and new sections covering std::jthread/std::stop_token, expanded semaphores, spurious wakeups, std::atomic with memory ordering, and the ABA problem. Producer-consumer example simplified. Pointer docs split: - pointers.md: trimmed to raw pointers, dangling/wild, ASan - smart_pointers.md (new): unique/shared/weak, custom deleters, enable_shared_from_this, atomic smart pointers - shared_ptr_use_cases.md (new): 12 patterns where shared ownership is the right tool, with minimal code each - references.md (new): refs, lvalue/rvalue, reference_wrapper, ref/cref - passing_returning: renumbered, added const shared_ptr<T>& form, enable_shared_from_this guidance - smart_pointers_class_member: PIMPL idiom, polymorphic ownership, Rule of Zero, thread-safety pointer-vs-pointee distinction New docs/lock_free_data_structures.md covering SPSC ring buffer, SPSC unbounded queue, MPSC (Vyukov intrusive), SPMC (Chase-Lev), MPMC (Vyukov bounded), hazard pointers + Treiber stack, and epoch-based reclamation, with full implementations. README updated: pointer docs split into separate entries; broken multithreading anchors fixed to numbered sections; lock-free docs listed under C++ System Design. clang_format.sh removed; clang-format is now driven from CMakeLists. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 5def127 commit adf5f83

11 files changed

Lines changed: 3109 additions & 1597 deletions

README.md

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,12 @@ This change ensures that VSCode uses the "Ninja Multi-Config" generator by defau
212212
- [Register Keyword](docs/register.md)
213213
- [Regex](docs/regex.md)
214214
- [Pseudo-random Number Generation, Distributions](docs/random_number.md)
215-
- [Raw Pointers, Smart (Shared, Unique, Weak) Pointers, Reference, addressof, reference_wrapper, std::ref](docs/pointers.md)
215+
- [Raw Pointers, Wild/Dangling, Memory Safety](docs/pointers.md)
216+
- [Smart Pointers (unique_ptr, shared_ptr, weak_ptr, atomic smart pointers)](docs/smart_pointers.md)
217+
- [When to Use shared_ptr — 12 Concrete Patterns](docs/shared_ptr_use_cases.md)
216218
- [Passing/ Returning Smart Pointers To/ From Functions](docs/passing_returning_smart_pointers_to_from_functions.md)
217219
- [Smart Pointers Class Member](docs/smart_pointers_class_member.md)
220+
- [References, Lvalue/Rvalue, reference_wrapper, std::ref / std::cref](docs/references.md)
218221
- [Return, Abort, Exit, Throw, Terminate](docs/return_abort_exit_throw_terminate.md)
219222
- [Scope Resolution Operator](docs/scope_resolution_operator.md)
220223
- [Scope and Life Cycle of Objects Returned by Functions](docs/scope_and_life_cycle_of_objects_returned_by_functions.md)
@@ -269,26 +272,22 @@ This change ensures that VSCode uses the "Ninja Multi-Config" generator by defau
269272
- [Virtual Function Abstract Class](docs/virtual_function_abstract_class.md)
270273
- [Virtual Destructor, Virtual Constructor](docs/virtual_destructor_virtual_constructor.md)
271274
* [Multithreading and Process](#)
272-
- [Process, Inter Process Communication (IPC), Process Tree, Process Control Block (PCB](docs/process.md)
273-
- [Creating (Thread Callable Objects), Terminating Threads](docs/multithreading.md#creation_and_termination)
274-
- [Over Subscription](docs/multithreading.md#over_subscrition)
275-
- [Differentiating Between Threads](docs/multithreading.md#differentiating_between_threads)
276-
- [Sleeping Threads](docs/multithreading.md#sleeping_threads)
277-
- [Joining/ Detaching Threads, Joinable Detachable](docs/multithreading.md#join_detach_threads)
278-
- [Threads Yield](docs/multithreading.md#yield)
279-
- [Thread Synchronization](docs/multithreading.md#thread_synchronization)
280-
- [Racing Condition](docs/multithreading.md#racing_condition)
281-
- [Mutex](docs/multithreading.md#mutex)
282-
- [Semaphor](docs/multithreading.md#semaphor)
283-
- [Thread Safe](docs/multithreading.md#thread_safe)
284-
- [Dead Lock](docs/multithreading.md#dead_lock)
285-
- [Lock Guard](docs/multithreading.md#lock_guard)
286-
- [Scoped Lock](docs/multithreading.md#scoped_lock)
287-
- [Unique Lock](docs/multithreading.md#unique_lock)
288-
- [Condition Variable](docs/multithreading.md#condition_variable)
289-
- [Future, Promise and async](docs/multithreading.md#async_future_promise)
290-
- [Packaged Task](docs/multithreading.md#packaged_task)
291-
- [Event handling/ Concurrency/ Thread design pattern](docs/thread_design_pattern.md)
275+
- [Process, Inter Process Communication (IPC), Process Tree, Process Control Block (PCB)](docs/process.md)
276+
- [Multithreading — Overview](docs/multithreading.md#1-overview)
277+
- [Creating and Terminating Threads (function pointer, member function, functor, lambda)](docs/multithreading.md#2-creating-and-terminating-threads)
278+
- [Joining and Detaching Threads](docs/multithreading.md#27-joining-threads)
279+
- [std::jthread and std::stop_token (C++20)](docs/multithreading.md#29-stdjthread-c20)
280+
- [Hardware Concurrency and Oversubscription](docs/multithreading.md#32-hardware-concurrency-and-oversubscription)
281+
- [Thread Identity, Sleeping, Yielding](docs/multithreading.md#3-thread-properties)
282+
- [Race Conditions vs Data Races](docs/multithreading.md#411-race-condition-vs-data-race)
283+
- [Mutex (std::scoped_lock, lock_guard, unique_lock)](docs/multithreading.md#42-mutex)
284+
- [Deadlock and How to Avoid It](docs/multithreading.md#423-deadlock)
285+
- [Semaphores (counting, binary)](docs/multithreading.md#43-semaphores)
286+
- [Condition Variables and Spurious Wakeups](docs/multithreading.md#44-condition-variables)
287+
- [std::future, std::async, std::promise, std::packaged_task](docs/multithreading.md#5-async-tasks-and-stdfuture)
288+
- [std::atomic, Memory Ordering, ABA Problem](docs/multithreading.md#6-stdatomic)
289+
- [Designing Thread-Safe Classes](docs/multithreading.md#7-designing-thread-safe-classes)
290+
- [Event handling / Concurrency / Thread Design Patterns](docs/thread_design_pattern.md)
292291

293292
## [Advance C++ Concepts and Idioms](#)
294293

@@ -395,7 +394,7 @@ This change ensures that VSCode uses the "Ninja Multi-Config" generator by defau
395394
- [Memory Management Strategies (Pool, Arena, Slab Allocators)](docs/system_design/memory_management.md)
396395
- [Object-Oriented Design Patterns (Factory, Singleton, Observer, Strategy)](docs/system_design/design_patterns.md)
397396
- [Concurrency Patterns (Thread Pool, Producer-Consumer, Active Object)](docs/system_design/concurrency_patterns.md)
398-
- [Lock-Free and Wait-Free Data Structures](docs/system_design/lock_free_structures.md)
397+
- [Lock-Free Data Structures (SPSC/SPMC/MPMC, ring buffers, hazard pointers, RCU)](docs/lock_free_data_structures.md)
399398
- [Cache-Friendly Data Structures and Data-Oriented Design](docs/system_design/cache_friendly_design.md)
400399
- [Plugin Architecture and Dynamic Loading](docs/system_design/plugin_architecture.md)
401400
- [Event-Driven Architecture and State Machines](docs/system_design/event_driven_state_machines.md)

clang_format.sh

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)