You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This change deepens three fragile modules by moving hidden invariants behind their own interfaces instead of forcing callers and future maintainers to remember them.
The queue cell will store `std::optional<T>` instead of a permanently live `T`. This removes the accidental default-constructible requirement and gives the module a real interface for generic payloads. The queue will also expose an rvalue enqueue path so move-only and expensive-to-copy types can cross the seam safely.
12
+
13
+
### 2. `Buffer` processing absorbs the empty-buffer invariant
14
+
15
+
The move-semantics example currently requires callers to know that `buf.data()[0]` is only valid when `size() > 0`. That is a shallow interface. The hardening change moves the empty-buffer check into the processing helpers so the module remains safe for default-constructed and zero-sized buffers.
16
+
17
+
### 3. Modern C++ example headers become explicitly link-safe
18
+
19
+
The repository treats these example headers as header-only modules. Non-template free functions defined in headers will be marked `inline`, and a dedicated multi-translation-unit smoke target will prove the contract during normal builds.
20
+
21
+
## Testing Strategy
22
+
23
+
1. Add a failing queue test that uses non-default-constructible and move-only payloads.
24
+
2. Add a failing move-semantics test that exercises empty buffers.
25
+
3. Add a failing multi-translation-unit smoke target for the modern C++ headers.
26
+
4. Apply the minimal production changes to make each loop pass.
27
+
5. Re-run the full preset-driven debug validation path.
Harden the header-only teaching modules where the current interface promises more than the implementation can safely deliver, focusing on queue payload support, empty-buffer safety, and multi-translation-unit link safety.
6
+
7
+
## Motivation
8
+
9
+
The repository is in closure and hardening mode. Several teaching modules already pass today's tests, but still carry design drift that weakens long-term maintainability:
10
+
11
+
1.`MPMCQueue` documents generic payload support, yet its implementation requires default-constructible element types and does not expose a move-oriented enqueue path.
12
+
2. The move-semantics example leaks a hidden caller invariant: `process_by_copy` and `process_by_ref` dereference element zero even when the buffer is empty.
13
+
3. Header-defined non-template functions in the modern C++ examples are not explicitly `inline`, which makes the header-only contract fragile across multiple translation units.
14
+
15
+
## Scope
16
+
17
+
- Harden the concurrency queue interface so the implementation matches its documented payload story.
18
+
- Harden the move-semantics example against empty-buffer use.
19
+
- Enforce link-safe header-only behavior in modern C++ example headers.
20
+
- Add targeted regression coverage for each fix.
21
+
22
+
## Out of Scope
23
+
24
+
- New performance claims or benchmark rewrites.
25
+
- Broad API redesign across unrelated modules.
26
+
- Reworking the docs site or unrelated repository governance surfaces.
0 commit comments