Document --threads, -j and throw an error when it's used on a non-threaded perl
This commit is contained in:
parent
fc76104aa7
commit
63ff01764c
@ -85,7 +85,8 @@ The author is Alessandro Ranellucci (me).
|
|||||||
-o, --output <file> File to output gcode to (by default, the file will be saved
|
-o, --output <file> File to output gcode to (by default, the file will be saved
|
||||||
into the same directory as the input file using the
|
into the same directory as the input file using the
|
||||||
--output-filename-format to generate the filename)
|
--output-filename-format to generate the filename)
|
||||||
|
-j, --threads <num> Number of threads to use (1+, default: 4)
|
||||||
|
|
||||||
Output options:
|
Output options:
|
||||||
--output-filename-format
|
--output-filename-format
|
||||||
Output file name format; all config options enclosed in brackets
|
Output file name format; all config options enclosed in brackets
|
||||||
|
@ -38,7 +38,8 @@ use Slic3r::Surface;
|
|||||||
use Slic3r::TriangleMesh;
|
use Slic3r::TriangleMesh;
|
||||||
use Slic3r::TriangleMesh::IntersectionLine;
|
use Slic3r::TriangleMesh::IntersectionLine;
|
||||||
|
|
||||||
our $threads = 4;
|
our $have_threads = $Config{useithreads} && eval "use threads; use Thread::Queue; 1";
|
||||||
|
our $threads = $have_threads ? 4 : undef;
|
||||||
|
|
||||||
# miscellaneous options
|
# miscellaneous options
|
||||||
our $notes = '';
|
our $notes = '';
|
||||||
@ -146,7 +147,7 @@ our $duplicate_distance = 6; # mm
|
|||||||
sub parallelize {
|
sub parallelize {
|
||||||
my %params = @_;
|
my %params = @_;
|
||||||
|
|
||||||
if (!$params{disable} && $Config{useithreads} && $Slic3r::threads > 1 && eval "use threads; use Thread::Queue; 1") {
|
if (!$params{disable} && $Slic3r::have_threads && $Slic3r::threads > 1) {
|
||||||
my $q = Thread::Queue->new;
|
my $q = Thread::Queue->new;
|
||||||
$q->enqueue(@{ $params{items} }, (map undef, 1..$Slic3r::threads));
|
$q->enqueue(@{ $params{items} }, (map undef, 1..$Slic3r::threads));
|
||||||
|
|
||||||
|
@ -507,6 +507,12 @@ sub validate_cli {
|
|||||||
|
|
||||||
sub validate {
|
sub validate {
|
||||||
my $class = shift;
|
my $class = shift;
|
||||||
|
|
||||||
|
# -j, --threads
|
||||||
|
die "Invalid value for --threads\n"
|
||||||
|
if defined $Slic3r::threads && $Slic3r::threads < 1;
|
||||||
|
die "Your perl wasn't built with multithread support\n"
|
||||||
|
if defined $Slic3r::threads && !$Slic3r::have_threads;
|
||||||
|
|
||||||
# --layer-height
|
# --layer-height
|
||||||
die "Invalid value for --layer-height\n"
|
die "Invalid value for --layer-height\n"
|
||||||
|
@ -95,6 +95,13 @@ if (@ARGV) {
|
|||||||
sub usage {
|
sub usage {
|
||||||
my ($exit_code) = @_;
|
my ($exit_code) = @_;
|
||||||
|
|
||||||
|
my $j = '';
|
||||||
|
if ($Slic3r::have_threads) {
|
||||||
|
$j = <<"EOF";
|
||||||
|
-j, --threads <num> Number of threads to use (1+, default: $Slic3r::threads)
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
print <<"EOF";
|
print <<"EOF";
|
||||||
Slic3r $Slic3r::VERSION is a STL-to-GCODE translator for RepRap 3D printers
|
Slic3r $Slic3r::VERSION is a STL-to-GCODE translator for RepRap 3D printers
|
||||||
written by Alessandro Ranellucci <aar\@cpan.org> - http://slic3r.org/
|
written by Alessandro Ranellucci <aar\@cpan.org> - http://slic3r.org/
|
||||||
@ -108,7 +115,7 @@ Usage: slic3r.pl [ OPTIONS ] file.stl
|
|||||||
-o, --output <file> File to output gcode to (by default, the file will be saved
|
-o, --output <file> File to output gcode to (by default, the file will be saved
|
||||||
into the same directory as the input file using the
|
into the same directory as the input file using the
|
||||||
--output-filename-format to generate the filename)
|
--output-filename-format to generate the filename)
|
||||||
|
$j
|
||||||
Output options:
|
Output options:
|
||||||
--output-filename-format
|
--output-filename-format
|
||||||
Output file name format; all config options enclosed in brackets
|
Output file name format; all config options enclosed in brackets
|
||||||
|
Loading…
Reference in New Issue
Block a user