X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=perl%2FAmanda%2FMainLoop.pm;h=98ce06f79427f0bf7d70221df006ccb2e721ae56;hb=cd0b924f27312d57bd42f6c4fae2b795139e2d0b;hp=5fbec198e81b2f8c0ba64526fd90d2611ad3c346;hpb=011a59f5a54864108a16af570a6b287410597cc2;p=debian%2Famanda diff --git a/perl/Amanda/MainLoop.pm b/perl/Amanda/MainLoop.pm index 5fbec19..98ce06f 100644 --- a/perl/Amanda/MainLoop.pm +++ b/perl/Amanda/MainLoop.pm @@ -498,6 +498,13 @@ To do the same for a single step, add the same keyword to the C invocation step immediate => 1, connect => sub { .. }; +In some case, you want to execute some code when the step finish, it can +be done by defining a finalize code in define_steps: + + my $steps = define_steps + cb_ref => \$finished_cb, + finalize => sub { .. }; + =head2 JOINING ASYNCHRONOUS "THREADS" With slow operations, it is often useful to perform multiple operations @@ -989,6 +996,7 @@ push @EXPORT_OK, "synchronized"; sub define_steps (@) { my (%params) = @_; my $cb_ref = $params{'cb_ref'}; + my $finalize = $params{'finalize'}; my %steps; croak "cb_ref is undefined" unless defined $cb_ref; @@ -1003,6 +1011,7 @@ push @EXPORT_OK, "synchronized"; $$cb_ref = sub { %steps = (); $current_steps = undef; + $finalize->() if defined($finalize); goto $orig_cb; };