mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-12 09:17:52 -06:00
Follow up, unify boost::thread usage.
This commit is contained in:
parent
67f55d3b23
commit
ad0a38e419
5 changed files with 33 additions and 10 deletions
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…
Add table
Add a link
Reference in a new issue