mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-13 01:37:53 -06:00
Multithreaded mesh processing. #154
This commit is contained in:
parent
a800b97fdd
commit
68b48fa807
3 changed files with 55 additions and 2 deletions
|
@ -14,6 +14,7 @@ sub debugf {
|
|||
printf @_ if $debug;
|
||||
}
|
||||
|
||||
use Config;
|
||||
use Slic3r::Config;
|
||||
use Slic3r::ExPolygon;
|
||||
use Slic3r::Extruder;
|
||||
|
@ -141,4 +142,20 @@ our $duplicate_x = 1;
|
|||
our $duplicate_y = 1;
|
||||
our $duplicate_distance = 6; # mm
|
||||
|
||||
sub parallelize {
|
||||
my %params = @_;
|
||||
|
||||
if (!$params{disable} && $Config{useithreads} && $Slic3r::threads > 1 && eval "use threads; use Thread::Queue; 1") {
|
||||
my $q = Thread::Queue->new;
|
||||
$q->enqueue(@{ $params{items} }, (map undef, 1..$Slic3r::threads));
|
||||
|
||||
my $thread_cb = sub { $params{thread_cb}->($q) };
|
||||
foreach my $th (map threads->create($thread_cb), 1..$Slic3r::threads) {
|
||||
$params{collect_cb}->($th->join);
|
||||
}
|
||||
} else {
|
||||
$params{no_threads_cb}->();
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue