Subject: [Boost-bugs] [Boost C++ Libraries] #8600: wait_for_any hangs, if called with multiple copies of shared_future referencing same task
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-05-21 11:50:16
#8600: wait_for_any hangs, if called with multiple copies of shared_future
referencing same task
--------------------------------------------------+-------------------------
Reporter: Martin Apel <martin.apel@â¦> | Owner: anthonyw
Type: Bugs | Status: new
Milestone: To Be Determined | Component: thread
Version: Boost 1.53.0 | Severity: Problem
Keywords: |
--------------------------------------------------+-------------------------
The following small test program shows the problem:
{{{
#include <iostream>
#include <boost/thread.hpp>
int calculate_the_answer_to_life_the_universe_and_everything()
{
return 42;
}
int main(int argc, char* argv[])
{
boost::packaged_task<int>
pt(calculate_the_answer_to_life_the_universe_and_everything);
boost::shared_future<int> fi1 =
boost::shared_future<int>(pt.get_future());
boost::shared_future<int> fi2 = fi1;
boost::thread task(boost::move(pt)); // launch task on a thread
boost::wait_for_any(fi1, fi2);
std::cout << "Wait for any returned\n";
return (0);
}
}}}
This program hangs infinitely in the call to boost::wait_for_any. From the
docs I would expect this to work, because it's allowed to copy
shared_futures. If this is not allowed, a possibility would be needed, to
find out, if two shared_futures point to the same task or not. Currently
wait_for_any is unusable, if there are chances, that multiple
shared_futures point to the same result.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/8600> 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:13 UTC