【发布时间】:2011-05-18 15:54:26
【问题描述】:
有没有办法配置 boost::thread 堆栈大小?
【问题讨论】:
标签: c++ multithreading
有没有办法配置 boost::thread 堆栈大小?
【问题讨论】:
标签: c++ multithreading
据我所知,它继承了新线程的进程默认值。
【讨论】:
不,AFAIK。
也许您可以尝试使用native_handle() 线程的成员函数并通过调用操作系统的 API 来设置堆栈大小(在 POSIX 系统上可能是pthread_attr_setstacksize()?)。
【讨论】:
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);
希望将来可以帮助某人。
【讨论】: