Files
obitools4/autodoc/docmd/pkg/obiutils/pipe.md
T
Eric Coissac 8c7017a99d ⬆️ version bump to v4.5
- Update obioptions.Version from "Release 4.4.29" to "/v/ Release v5"
- Update version.txt from 4.29 → .30
(automated by Makefile)
2026-04-13 13:34:53 +02:00

37 lines
1.5 KiB
Markdown

# `obiutils` Package: Pipe Synchronization Utilities
This Go package provides lightweight synchronization primitives for managing concurrent pipeline execution, particularly useful in CLI or batch-processing applications.
## Core Components
- **`globalLocker`:** A `sync.WaitGroup` tracking active pipeline goroutines.
- **`globalLockerCounter`:** An integer counter for logging/debugging the number of active pipes.
## Public Functions
### `RegisterAPipe()`
- Increments both the WaitGroup and counter.
- Logs current count at debug level (`log.Debugln`).
- Typically called when starting a new pipeline stage or goroutine.
### `UnregisterPipe()`
- Decrements the WaitGroup and counter.
- Logs updated count at debug level.
- Should be invoked when a pipeline finishes (e.g., `defer UnregisterPipe()`).
### `WaitForLastPipe()`
- Blocks until all registered pipes complete (`globalLocker.Wait()`).
- Intended to be called at the end of `main()`, ensuring graceful shutdown.
## Semantic Use Case
Enables safe, concurrent execution of multiple independent pipelines (e.g., data processing stages), ensuring the program waits for all to finish before exiting — without explicit channel or mutex management.
## Design Notes
- **Thread-safe** via `sync.WaitGroup`.
- **Minimalist**: No error handling; assumes correct usage.
- **Logging-focused** for observability in development/debug builds.
> ⚠️ Not production-ready without additional safeguards (e.g., panic recovery, timeout support).