mirror of
https://github.com/lightningnetwork/lnd.git
synced 2026-08-19 13:17:32 +02:00
In this commit, we add ContextFromQuit, a utility for bridging the quit
channel shutdown pattern to context.Context-based cancellation.
Several subsystems in lnd use a plain quit <-chan struct{} for
cooperative shutdown rather than a context.Context. When those
subsystems need to await a Future[error], which uses a context for
cancellation, they need a way to derive a context that is cancelled
when the quit channel closes.
ContextFromQuit does exactly that: it returns a context tied to
context.Background() plus a cancel function, and spins up a minimal
goroutine that cancels the context as soon as quit is closed. The
returned cancel must be called (deferred at the call site) so the
goroutine exits when the enclosing operation completes normally before
shutdown.
This is a pure utility with no policy and no default timeout, so
callers remain in full control of lifetime.
|
||
|---|---|---|
| .. | ||
| chan.go | ||
| context.go | ||
| errors.go | ||
| fs.go | ||
| fs_test.go | ||
| log.go | ||
| memory.go | ||
| README.md | ||
| stream.go | ||
| sync_map.go | ||
| sync_map_bench_test.go | ||
| sync_map_test.go | ||
lnutils
This package provides fundamental types and utility functions that can be used by all other packages.