Follow up, unify boost::thread usage.
This commit is contained in:
parent
67f55d3b23
commit
ad0a38e419
@ -156,6 +156,7 @@ set(SLIC3R_GUI_SOURCES
|
|||||||
Utils/UndoRedo.hpp
|
Utils/UndoRedo.hpp
|
||||||
Utils/HexFile.cpp
|
Utils/HexFile.cpp
|
||||||
Utils/HexFile.hpp
|
Utils/HexFile.hpp
|
||||||
|
Utils/Thread.hpp
|
||||||
)
|
)
|
||||||
|
|
||||||
if (APPLE)
|
if (APPLE)
|
||||||
|
@ -261,11 +261,7 @@ bool BackgroundSlicingProcess::start()
|
|||||||
if (m_state == STATE_INITIAL) {
|
if (m_state == STATE_INITIAL) {
|
||||||
// The worker thread is not running yet. Start it.
|
// The worker thread is not running yet. Start it.
|
||||||
assert(! m_thread.joinable());
|
assert(! m_thread.joinable());
|
||||||
boost::thread::attributes attrs;
|
m_thread = create_thread([this]{this->thread_proc_safe();});
|
||||||
// Duplicating the stack allocation size of Thread Building Block worker threads of the thread pool:
|
|
||||||
// allocate 4MB on a 64bit system, allocate 2MB on a 32bit system by default.
|
|
||||||
attrs.set_stack_size((sizeof(void*) == 4) ? (2048 * 1024) : (4096 * 1024));
|
|
||||||
m_thread = boost::thread(attrs, [this]{this->thread_proc_safe();});
|
|
||||||
// Wait until the worker thread is ready to execute the background processing task.
|
// Wait until the worker thread is ready to execute the background processing task.
|
||||||
m_condition.wait(lck, [this](){ return m_state == STATE_IDLE; });
|
m_condition.wait(lck, [this](){ return m_state == STATE_IDLE; });
|
||||||
}
|
}
|
||||||
|
@ -6,12 +6,12 @@
|
|||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
#include <boost/thread.hpp>
|
|
||||||
|
|
||||||
#include <wx/event.h>
|
#include <wx/event.h>
|
||||||
|
|
||||||
#include "libslic3r/Print.hpp"
|
#include "libslic3r/Print.hpp"
|
||||||
#include "slic3r/Utils/PrintHost.hpp"
|
#include "slic3r/Utils/PrintHost.hpp"
|
||||||
|
#include "slic3r/Utils/Thread.hpp"
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
#include <boost/filesystem/path.hpp>
|
#include <boost/filesystem/path.hpp>
|
||||||
#include <boost/filesystem/operations.hpp>
|
#include <boost/filesystem/operations.hpp>
|
||||||
#include <boost/log/trivial.hpp>
|
#include <boost/log/trivial.hpp>
|
||||||
#include <boost/thread.hpp>
|
|
||||||
|
|
||||||
#include <wx/sizer.h>
|
#include <wx/sizer.h>
|
||||||
#include <wx/stattext.h>
|
#include <wx/stattext.h>
|
||||||
@ -76,6 +75,7 @@
|
|||||||
#include "../Utils/PrintHost.hpp"
|
#include "../Utils/PrintHost.hpp"
|
||||||
#include "../Utils/FixModelByWin10.hpp"
|
#include "../Utils/FixModelByWin10.hpp"
|
||||||
#include "../Utils/UndoRedo.hpp"
|
#include "../Utils/UndoRedo.hpp"
|
||||||
|
#include "../Utils/Thread.hpp"
|
||||||
|
|
||||||
#include <wx/glcanvas.h> // Needs to be last because reasons :-/
|
#include <wx/glcanvas.h> // Needs to be last because reasons :-/
|
||||||
#include "WipeTowerDialog.hpp"
|
#include "WipeTowerDialog.hpp"
|
||||||
@ -1537,9 +1537,7 @@ struct Plater::priv
|
|||||||
wxBeginBusyCursor();
|
wxBeginBusyCursor();
|
||||||
|
|
||||||
try { // Execute the job
|
try { // Execute the job
|
||||||
boost::thread::attributes attrs;
|
m_thread = create_thread([this] { this->run(); });
|
||||||
attrs.set_stack_size((sizeof(void*) == 4) ? (2048 * 1024) : (4096 * 1024));
|
|
||||||
m_thread = boost::thread(attrs, [this] { this->run(); });
|
|
||||||
} catch (std::exception &) {
|
} catch (std::exception &) {
|
||||||
update_status(status_range(),
|
update_status(status_range(),
|
||||||
_(L("ERROR: not enough resources to "
|
_(L("ERROR: not enough resources to "
|
||||||
|
28
src/slic3r/Utils/Thread.hpp
Normal file
28
src/slic3r/Utils/Thread.hpp
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#ifndef THREAD_HPP
|
||||||
|
#define THREAD_HPP
|
||||||
|
|
||||||
|
#include <utility>
|
||||||
|
#include <boost/thread.hpp>
|
||||||
|
|
||||||
|
namespace Slic3r {
|
||||||
|
|
||||||
|
template<class Fn>
|
||||||
|
inline boost::thread create_thread(boost::thread::attributes &attrs, Fn &&fn)
|
||||||
|
{
|
||||||
|
// Duplicating the stack allocation size of Thread Building Block worker
|
||||||
|
// threads of the thread pool: allocate 4MB on a 64bit system, allocate 2MB
|
||||||
|
// on a 32bit system by default.
|
||||||
|
|
||||||
|
attrs.set_stack_size((sizeof(void*) == 4) ? (2048 * 1024) : (4096 * 1024));
|
||||||
|
return boost::thread{attrs, std::forward<Fn>(fn)};
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class Fn> inline boost::thread create_thread(Fn &&fn)
|
||||||
|
{
|
||||||
|
boost::thread::attributes attrs;
|
||||||
|
return create_thread(attrs, std::forward<Fn>(fn));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // THREAD_HPP
|
Loading…
Reference in New Issue
Block a user