mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-14 05:35:52 +08:00
Minor fixes to parallelize code
This commit is contained in:
parent
23b4f6b193
commit
5242b3e03a
@ -1248,8 +1248,12 @@ PrintConfigDef::PrintConfigDef()
|
||||
def->readonly = true;
|
||||
def->min = 1;
|
||||
def->max = 16;
|
||||
def->default_value = new ConfigOptionInt(boost::thread::hardware_concurrency() || 2);
|
||||
|
||||
{
|
||||
int threads = boost::thread::hardware_concurrency();
|
||||
if (threads == 0) threads = 2;
|
||||
def->default_value = new ConfigOptionInt(threads);
|
||||
}
|
||||
|
||||
def = this->add("toolchange_gcode", coString);
|
||||
def->label = "Tool change G-code";
|
||||
def->tooltip = "This custom code is inserted right before every extruder change. Note that you can use placeholder variables for all Slic3r settings as well as [previous_extruder] and [next_extruder].";
|
||||
|
@ -4,6 +4,7 @@
|
||||
// this needs to be included early for MSVC (listing it in Build.PL is not enough)
|
||||
#include <ostream>
|
||||
#include <iostream>
|
||||
#include <math.h>
|
||||
#include <queue>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
@ -90,9 +91,10 @@ template <class T> void
|
||||
parallelize(std::queue<T> queue, boost::function<void(T)> func,
|
||||
int threads_count = boost::thread::hardware_concurrency())
|
||||
{
|
||||
if (threads_count == 0) threads_count = 2;
|
||||
boost::mutex queue_mutex;
|
||||
boost::thread_group workers;
|
||||
for (int i = 0; i < threads_count; i++)
|
||||
for (int i = 0; i < fminf(threads_count, queue.size()); i++)
|
||||
workers.add_thread(new boost::thread(&_parallelize_do<T>, &queue, &queue_mutex, func));
|
||||
workers.join_all();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user