2 Thread::Cleanup - Hook thread destruction.
12 Thread::Cleanup::register {
13 my $tid = threads->tid();
14 warn "Thread $tid finished\n";
18 This module allows you to hook thread destruction without fiddling with
19 the internals of threads.
21 It acts globally on all the threads that may spawn anywhere in your
22 program, with the exception of the main thread.
29 Specify that the given block or code reference $coderef will have to be
30 called (in void context, without arguments) every time a thread finishes
31 its job. More precisely,
33 * it will always be called before the joining for joined threads ;
35 * it will be called for detached threads if and only if they terminate
36 before the main thread, and the hook will then fire at "END" time ;
38 * it won't trigger for the destruction of the main thread.
46 A C compiler. This module may happen to build with a C++ compiler as
47 well, but don't rely on it, as no guarantee is made in this regard.
54 Vincent Pit, "<perl at profvince.com>", <http://www.profvince.com>.
57 Please report any bugs or feature requests to "bug-thread-cleanup at
58 rt.cpan.org", or through the web interface at
59 <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Thread-Cleanup>. I will
60 be notified, and then you'll automatically be notified of progress on
61 your bug as I make changes.
64 You can find documentation for this module with the perldoc command.
66 perldoc Thread::Cleanup
69 Inspired by a question from TonyC on #p5p.
72 Copyright 2009,2010,2013 Vincent Pit, all rights reserved.
74 This program is free software; you can redistribute it and/or modify it
75 under the same terms as Perl itself.