Beispiel #1
0
int p2(boost::future<int>& f)
{
    BOOST_THREAD_LOG << "p2 <" << &f << BOOST_THREAD_END_LOG;
    BOOST_TEST(f.valid());
    int i = f.get();
    boost::this_thread::sleep_for(boost::chrono::milliseconds(500));
    BOOST_THREAD_LOG << "p2 <" << &f << BOOST_THREAD_END_LOG;
    return 2 * i;
}
void p3(boost::future<int> f)
{
  assert(f.is_ready());
  BOOST_THREAD_LOG << "p3 <" << &f << BOOST_THREAD_END_LOG;
  BOOST_TEST(f.valid());
  int i = f.get();
  boost::this_thread::sleep_for(boost::chrono::milliseconds(500));
  BOOST_THREAD_LOG << "p3 <" << &f << " " <<i << BOOST_THREAD_END_LOG;
  return;
}
Beispiel #3
0
int p2(boost::future<int> f)
{
  BOOST_THREAD_LOG
    << " P2 " << BOOST_THREAD_END_LOG;
  try
  {
    return 2 * f.get();
  }
  catch (std::exception& ex)
  {
    BOOST_THREAD_LOG
      << "ERRORRRRR " << ex.what() << "" << BOOST_THREAD_END_LOG;
    BOOST_ASSERT(false);
  }
  catch (...)
  {
    BOOST_THREAD_LOG
      << " ERRORRRRR exception thrown" << BOOST_THREAD_END_LOG;
    BOOST_ASSERT(false);
  }
  BOOST_THREAD_LOG
    << "P2>" << BOOST_THREAD_END_LOG;
  return 0;

}
Beispiel #4
0
void bar(boost::future<int> fooResult)
{
  try {
    std::cout << "bar" << std::endl;
    int i = fooResult.get(); // Code hangs on this line (Due to future already being locked by the set_value call)
    std::cout << "i: " << i << std::endl;
  } catch(...) {
    std::cout << __FILE__ << ":" << __LINE__ << std::endl;
  }
}
Beispiel #5
0
 servant_proxy(scheduler_proxy_type p, boost::future<CServant> s)
     : m_proxy(p)
     , m_servant()
 {
     bool ok = s.timed_wait(boost::posix_time::milliseconds(max_create_wait_ms));
     if(ok)
     {
         m_servant = boost::make_shared<servant_type>(std::move(s.get()));
         // servant ought not be empty
         if (!m_servant)
         {
             throw empty_servant();
         }
     }
     else
     {
         throw servant_proxy_timeout();
     }
 }
Beispiel #6
0
int p2(boost::future<int>& f)
{
  return 2 * f.get();
}
Beispiel #7
0
 result_type operator()(boost::future<boost::future<void> > future) const
 {
    future.get();
    return boost::make_ready_future();
 }