Require a recent threads.pm version because of upstream bug 85140 potentially causing deadlocks when stopping running threads. #2394
https://rt.cpan.org/Ticket/Display.html?id=85140
This commit is contained in:
parent
ac495e974a
commit
84760b8d59
1
Build.PL
1
Build.PL
@ -22,6 +22,7 @@ my %prereqs = qw(
|
|||||||
Test::More 0
|
Test::More 0
|
||||||
Thread::Semaphore 0
|
Thread::Semaphore 0
|
||||||
IO::Scalar 0
|
IO::Scalar 0
|
||||||
|
threads 1.96
|
||||||
Time::HiRes 0
|
Time::HiRes 0
|
||||||
);
|
);
|
||||||
my %recommends = qw(
|
my %recommends = qw(
|
||||||
|
@ -82,17 +82,21 @@ use constant EXTERNAL_INFILL_MARGIN => 3;
|
|||||||
use constant INSET_OVERLAP_TOLERANCE => 0.2;
|
use constant INSET_OVERLAP_TOLERANCE => 0.2;
|
||||||
|
|
||||||
# keep track of threads we created
|
# keep track of threads we created
|
||||||
my @threads : shared = ();
|
my @threads = ();
|
||||||
my $sema = Thread::Semaphore->new;
|
my $sema = Thread::Semaphore->new;
|
||||||
my $paused = 0;
|
my $paused = 0;
|
||||||
|
|
||||||
sub spawn_thread {
|
sub spawn_thread {
|
||||||
my ($cb) = @_;
|
my ($cb) = @_;
|
||||||
|
|
||||||
|
my $parent_tid = threads->tid;
|
||||||
|
|
||||||
@_ = ();
|
@_ = ();
|
||||||
my $thread = threads->create(sub {
|
my $thread = threads->create(sub {
|
||||||
|
Slic3r::debugf "Starting thread %d (parent: %d)...\n", threads->tid, $parent_tid;
|
||||||
local $SIG{'KILL'} = sub {
|
local $SIG{'KILL'} = sub {
|
||||||
Slic3r::debugf "Exiting thread...\n";
|
Slic3r::debugf "Exiting thread %d...\n", threads->tid;
|
||||||
|
kill_all_threads();
|
||||||
Slic3r::thread_cleanup();
|
Slic3r::thread_cleanup();
|
||||||
threads->exit();
|
threads->exit();
|
||||||
};
|
};
|
||||||
@ -205,6 +209,7 @@ sub kill_all_threads {
|
|||||||
# detach any running thread created in the current one
|
# detach any running thread created in the current one
|
||||||
my @killed = ();
|
my @killed = ();
|
||||||
foreach my $thread (get_running_threads()) {
|
foreach my $thread (get_running_threads()) {
|
||||||
|
Slic3r::debugf "Thread %d killing %d...\n", threads->tid, $thread->tid;
|
||||||
$thread->kill('KILL');
|
$thread->kill('KILL');
|
||||||
push @killed, $thread;
|
push @killed, $thread;
|
||||||
}
|
}
|
||||||
@ -212,7 +217,11 @@ sub kill_all_threads {
|
|||||||
# unlock semaphore before we block on wait
|
# unlock semaphore before we block on wait
|
||||||
# otherwise we'd get a deadlock if threads were paused
|
# otherwise we'd get a deadlock if threads were paused
|
||||||
resume_threads();
|
resume_threads();
|
||||||
$_->join for @killed; # block until threads are killed
|
foreach my $thread (@killed) {
|
||||||
|
Slic3r::debugf " Threads %d waiting for %d...\n", threads->tid, $thread->tid;
|
||||||
|
$thread->join; # block until threads are killed
|
||||||
|
Slic3r::debugf " Thread %d finished waiting for %d...\n", threads->tid, $thread->tid;
|
||||||
|
}
|
||||||
@threads = ();
|
@threads = ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user