本文整理汇总了C++中boost::promise::get_future方法的典型用法代码示例。如果您正苦于以下问题:C++ promise::get_future方法的具体用法?C++ promise::get_future怎么用?C++ promise::get_future使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::promise
的用法示例。
在下文中一共展示了promise::get_future方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
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();
}
示例2:
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();
};
示例3:
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);
}
示例4: main
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();
}
示例5: WorkItem
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())
{}
示例6: main
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();
}
示例7: main
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();
}
示例8:
layer_consumer() : first_frame_reported_(false)
{
first_frame_available_ = first_frame_promise_.get_future();
frame_buffer_.set_capacity(2);
}
示例9: Select
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(); }
示例10: RunCommand
RunCommand(const mongo::BSONObj& cmd, mongo::BSONObj& ret,
boost::unique_future<bool>& future) : cmd(cmd), ret(ret), future(future)
{
future = promise.get_future();
}