int main() { { boost::future<boost::csbl::unique_ptr<int> > f = p.get_future(); boost::thread(func).detach(); BOOST_TEST(*f.get() == 5); } { boost::future<boost::csbl::unique_ptr<int> > f = p2.get_future(); boost::thread(func2).detach(); BOOST_TEST(*f.get() == 5); } return boost::report_errors(); }
boost::future<autobahn::wamp_authenticate> on_challenge(const autobahn::wamp_challenge& challenge) { std::cerr << "responding to auth challenge: " << challenge.challenge() << std::endl; std::string signature = compute_wcs(m_secret, challenge.challenge()); challenge_future.set_value( autobahn::wamp_authenticate(signature) ); std::cerr << "signature: " << signature << std::endl; return challenge_future.get_future(); };
channel_consumer() : consumer_index_(next_consumer_index()) , first_frame_available_(first_frame_promise_.get_future()) , first_frame_reported_(false) { is_running_ = true; current_age_ = 0; frame_buffer_.set_capacity(3); }
int main() { { //boost::promise<int&> p; boost::future<int&> f = p.get_future(); //boost::thread(func, boost::move(p)).detach(); boost::thread(func).detach(); int r = f.get(); BOOST_TEST(r == 4); } return boost::report_errors(); }
WorkItem(const Request& req, ExtraSendFun* send_extra, ExtraRecvFun* recv_extra) : request(req) , request_tag(allocate_tag()) , request_type(vfsprotocol::RequestTraits<Request>::request_type) , request_desc(vfsprotocol::request_type_to_string(request_type)) , send_extra_fun(send_extra) , recv_extra_fun(recv_extra) // clang++ (3.8.0-2ubuntu3~trusty4) complains otherwise about // 'promise' being used unitialized when initializing 'future' , promise() , future(promise.get_future()) {}
int main() { { typedef int T; //boost::promise<T> p; boost::future<T> f = p.get_future(); //boost::thread(func, boost::move(p)).detach(); boost::thread(func).detach(); try { f.get(); BOOST_TEST(false); } catch (boost::wrap<int> i) { BOOST_TEST(i.value == 3); } catch (...) { BOOST_TEST(false); } } { typedef int T; boost::promise<T> p2; boost::future<T> f = p2.get_future(); //boost::thread(func, boost::move(p)).detach(); p = boost::move(p2); boost::thread(func).detach(); try { f.get(); BOOST_TEST(false); } catch (boost::wrap<int> i) { BOOST_TEST(i.value == 3); } catch (...) { BOOST_TEST(false); } } return boost::report_errors(); }
int main() { { //boost::promise<boost::interprocess::unique_ptr<int, boost::default_delete<int>> > p; boost::future<boost::interprocess::unique_ptr<int, boost::default_delete<int> > > f = p.get_future(); //boost::thread(func, boost::move(p)).detach(); boost::thread(func).detach(); BOOST_TEST(*f.get() == 5); } return boost::report_errors(); }
layer_consumer() : first_frame_reported_(false) { first_frame_available_ = first_frame_promise_.get_future(); frame_buffer_.set_capacity(2); }
Select(const std::string& container, const mongo::Query& query, QueryResults& results, boost::unique_future<bool>& future, int limit = 0) : container(container), query(query), results(results), future(future), promise(), limit(limit) { future = promise.get_future(); }
RunCommand(const mongo::BSONObj& cmd, mongo::BSONObj& ret, boost::unique_future<bool>& future) : cmd(cmd), ret(ret), future(future) { future = promise.get_future(); }