[Boost-bugs] [Boost C++ Libraries] #9654: try_join_for(0) returns false when thread has exited

Subject: [Boost-bugs] [Boost C++ Libraries] #9654: try_join_for(0) returns false when thread has exited
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-02-11 08:46:30


#9654: try_join_for(0) returns false when thread has exited
------------------------------+------------------------
 Reporter: ernest.galbrun@… | Owner: anthonyw
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: thread
  Version: Boost 1.55.0 | Severity: Regression
 Keywords: |
------------------------------+------------------------
 I use try_join_for(boost::chrono::milliseconds(0)) to check if my thread
 has finished.

 When upgrading from boost 53 to boost 55 I noticed that it now returns
 false systematically. It seems to work fine if I use any duration other
 than 0.

 Here is a minimal code that reproduces the problem, I work with visual
 studio 2012 x64:


 {{{
 #include <boost\thread.hpp>
 #include <iostream>

 void my_func(void){
         std::cout<<"This shouldn't take long...\n";
 }

 void main(void) {
         boost::thread * t = new boost::thread(my_func);
         int i = 0;
         while (! t->try_join_for(boost::chrono::milliseconds(1))) {
                 std::cout<<"iteration "<<++i<<'\n';
 boost::this_thread::sleep_for(boost::chrono::milliseconds(100));
         }
         std::cout << "first task finished\n";
         delete t;
         t = new boost::thread(my_func);
         i=0;
         while (! t->try_join_for(boost::chrono::milliseconds(0))) {
                 std::cout<<"iteration "<<++i<<'\n';
 boost::this_thread::sleep_for(boost::chrono::milliseconds(100));
         }
         std::cout << "second task finished\n";
 }
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/9654>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:15 UTC