diff options
author | Eric Wong <e@80x24.org> | 2022-11-28 05:32:04 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2022-11-28 23:38:57 +0000 |
commit | 4452b5ebd8f202d72260325768512230c93ef6f2 (patch) | |
tree | a2574f084f0042ebadb4f0aa5c009bac57bfbc9e /lib/PublicInbox | |
parent | 02d0dfd3f22f8f7c5d1e189dbe29034b9da9f510 (diff) | |
download | public-inbox-4452b5ebd8f202d72260325768512230c93ef6f2.tar.gz |
on_destroy: support ->cancel callback
We probably use this idiom elsewhere, but having this method around to make future use cases more readable is probably prudent.
Diffstat (limited to 'lib/PublicInbox')
-rw-r--r-- | lib/PublicInbox/OnDestroy.pm | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/PublicInbox/OnDestroy.pm b/lib/PublicInbox/OnDestroy.pm index 615bc450..d9a6cd24 100644 --- a/lib/PublicInbox/OnDestroy.pm +++ b/lib/PublicInbox/OnDestroy.pm @@ -1,13 +1,16 @@ -# Copyright (C) 2020-2021 all contributors <meta@public-inbox.org> +# Copyright (C) all contributors <meta@public-inbox.org> # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt> package PublicInbox::OnDestroy; +use v5.12; sub new { shift; # ($class, $cb, @args) bless [ @_ ], __PACKAGE__; } +sub cancel { @{$_[0]} = () } + sub DESTROY { my ($cb, @args) = @{$_[0]}; if (!ref($cb) && $cb) { |