【问题标题】:configuring boost::thread stack size配置 boost::thread 堆栈大小
【发布时间】:2011-05-18 15:54:26
【问题描述】:

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

【问题讨论】:

    标签: c++ multithreading


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

      不,AFAIK。

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

      【讨论】:

        【解决方案3】:

        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);
        

        希望将来可以帮助某人。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2018-06-29
          • 1970-01-01
          • 2021-06-12
          • 2016-12-07
          • 2014-05-17
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多