Prevent concurrency issues by blocking until background threads are killed

This commit is contained in:
Alessandro Ranellucci 2014-07-04 12:12:15 +02:00
parent b926079fd5
commit 07f8fb1264

View File

@ -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 = ();
} }