Breaking changes in Boost.Thread 3.0.0

后端 未结 2 1530
無奈伤痛
無奈伤痛 2021-01-18 01:16

In the release notes of version 1.50.0 of the Boost libraries I noted two breaking changes (see here):

#6266 Breaking change: thread destructor should ca

2条回答
  •  轮回少年
    2021-01-18 01:57

    The following code used to work correctly, but with v3 the program would be aborted as t leaves its scope, because thread::~thread calls std::terminate, instead of silently detaching from the thread:

    #include  
    #include 
    
    void f()
    {}
    
    int main() 
    { 
      {
        boost::thread t(f);
      }
      std::cout << "exiting gracefully" << std::endl;
    } 
    

提交回复
热议问题