Prevent concurrency issues by blocking until background threads are killed
This commit is contained in:
parent
b926079fd5
commit
07f8fb1264
@ -190,10 +190,12 @@ sub thread_cleanup {
|
|||||||
|
|
||||||
sub kill_all_threads {
|
sub kill_all_threads {
|
||||||
# detach any running thread created in the current one
|
# detach any running thread created in the current one
|
||||||
|
my @killed = ();
|
||||||
foreach my $thread (grep defined($_), map threads->object($_), @threads) {
|
foreach my $thread (grep defined($_), map threads->object($_), @threads) {
|
||||||
$thread->kill('KILL');
|
$thread->kill('KILL');
|
||||||
$thread->detach;
|
push @killed, $thread;
|
||||||
}
|
}
|
||||||
|
$_->join for @killed; # block until threads are killed
|
||||||
@threads = ();
|
@threads = ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user