From 4452b5ebd8f202d72260325768512230c93ef6f2 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 28 Nov 2022 05:32:04 +0000 Subject: 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. --- lib/PublicInbox/OnDestroy.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/PublicInbox') 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 +# Copyright (C) all contributors # License: AGPL-3.0+ 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) { -- cgit v1.2.3-24-ge0c7