mirror of
https://github.com/Nanaloveyuki/BitLogger.git
synced 2026-07-30 15:04:48 +00:00
📝 clarify async lifecycle docs
This commit is contained in:
@@ -39,6 +39,7 @@ Detailed rules explaining key parameters and behaviors
|
||||
- `clear=true` immediately closes and abandons pending records.
|
||||
- In runtimes where shutdown waits for workers, the method then waits until `is_running()` becomes `false` before returning.
|
||||
- In the current backend split, native-worker runtimes enable both the post-`wait_idle()` clear fallback and the final wait-for-worker phase, while compatibility runtimes skip both extra steps.
|
||||
- Because `clear=false` delegates to `wait_idle()` first, shutdown can also wait indefinitely when pending records exist but no worker is making progress and no failure flag is raised.
|
||||
|
||||
### How to Use
|
||||
|
||||
@@ -71,6 +72,8 @@ e.g.:
|
||||
|
||||
- In compatibility-style runtimes without background-worker waiting, shutdown still closes the logger but may not perform the extra wait-for-worker phase described for native-worker runtimes.
|
||||
|
||||
- If pending work exists but no worker was started, `shutdown(clear=false)` may never reach its later close step because it is still waiting inside `wait_idle()`.
|
||||
|
||||
- If callers skip `shutdown()` and only inspect flags manually, it is easier to leave the worker lifecycle in an unclear state.
|
||||
|
||||
### Notes
|
||||
@@ -82,3 +85,5 @@ e.g.:
|
||||
3. Choose `clear=true` only when loss of queued records is acceptable.
|
||||
|
||||
4. Pair it with `state()` or focused counters when tests need to assert whether shutdown drained backlog or converted it into dropped records.
|
||||
|
||||
5. Prefer `shutdown(clear=true)` when teardown must not depend on a still-running drain worker.
|
||||
|
||||
Reference in New Issue
Block a user