Skip to content

Commit 5307b5e

Browse files
committed
Make BackgroundProcessor #[must_use] to avoid dropping immediately
It is easy for users to have a bug where they drop a `BackgroundProcessor` immediately, causing it to start and then immediately stop. Instead, add a `#[must_use]` tag to provide a compiler warning for such instances.
1 parent cab2ca8 commit 5307b5e

File tree

1 file changed

+1
-0
lines changed
  • lightning-background-processor/src

1 file changed

+1
-0
lines changed

lightning-background-processor/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ use std::ops::Deref;
3939
/// then there is a risk of channels force-closing on startup when the manager realizes it's
4040
/// outdated. However, as long as `ChannelMonitor` backups are sound, no funds besides those used
4141
/// for unilateral chain closure fees are at risk.
42+
#[must_use = "BackgroundProcessor will immediately stop on drop. It should be stored until shutdown."]
4243
pub struct BackgroundProcessor {
4344
stop_thread: Arc<AtomicBool>,
4445
thread_handle: Option<JoinHandle<Result<(), std::io::Error>>>,

0 commit comments

Comments
 (0)