配置boost :: thread堆栈大小

时间:2010-12-01 17:53:59

标签: c++ multithreading

有没有办法配置boost :: thread堆栈大小?

3 个答案:

答案 0 :(得分:2)

不,AFAIK。

也许您可以尝试使用native_handle()线程的成员函数,并通过调用OS的API来设置堆栈大小(可能是POSIX系统上的pthread_attr_setstacksize()。)。

答案 1 :(得分:0)

我不知道,它继承了新线程的进程默认值。

答案 2 :(得分:0)

Boost得到了发展,并且有一个解决方案:https://www.boost.org/doc/libs/1_61_0/doc/html/thread/thread_management.html#thread.thread_management.tutorial.attributes

缩小版本

boost::thread::attributes attrs;
attrs.set_stack_size(4096*10);
boost::thread deep_thought(attrs, find_the_question, 42);

希望将来可以帮助某个人。

相关问题