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(); };
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(); }
static void ramhog_gen_pad_mt(boost::promise<bool> &done, const uint8_t *input, size_t input_size, uint32_t C, uint32_t padIndex, uint64_t *padOut, bool fForMiner, CBlockIndex *pindexForBest) { if (fForMiner && pindexForBest != pindexBest) { done.set_value(error("ramhog_gen_pad_mt(): Interrupted from new best block")); return; } ramhog_gen_pad(input, input_size, C, padIndex, padOut); done.set_value(true); }
void accumulate(boost::promise<int> &p) { int sum = 0; for (int i = 0; i < 5; ++i) sum += i; p.set_value(sum); }
void promise_task(boost::promise<std::string> & promise) { std::cout << "promise_task" << std::endl; // sleep (2); promise.set_value("PROMISE"); }
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); }
void wait_callback(boost::promise<int>& pi) { boost::lock_guard<boost::mutex> lk(callback_mutex); ++callback_called; try { pi.set_value(42); } catch(...) { } }
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(); }
virtual boost::unique_future<bool> send(const safe_ptr<read_frame>& frame) override { bool pushed = frame_buffer_.try_push(frame); if (pushed && !first_frame_reported_) { first_frame_promise_.set_value(); first_frame_reported_ = true; } return caspar::wrap_as_future(is_running_.load()); }
virtual void send(const safe_ptr<basic_frame>& src_frame) override { bool pushed = frame_buffer_.try_push(src_frame); // frame_buffer_.push(src_frame); if (pushed && !first_frame_reported_) //changed to fix compilation //if (!first_frame_reported_) { first_frame_promise_.set_value(); first_frame_reported_ = true; } }
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(); }
void func1(boost::promise<int> p) { boost::this_thread::sleep_for(ms(500)); p.set_value(3); }
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(); }
void func() { p.set_exception_at_thread_exit(boost::make_exception_ptr(3)); }
RunCommand(const mongo::BSONObj& cmd, mongo::BSONObj& ret, boost::unique_future<bool>& future) : cmd(cmd), ret(ret), future(future) { future = promise.get_future(); }
void func() { boost::interprocess::unique_ptr<int, boost::default_delete<int> > uptr(new int(5)); p.set_value_at_thread_exit(boost::move(uptr)); }
void func6(boost::promise<void> p) { boost::this_thread::sleep_for(boost::chrono::milliseconds(500)); p.set_exception(boost::make_exception_ptr('c')); }
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(); }
void func4(boost::promise<int&> p) { boost::this_thread::sleep_for(boost::chrono::milliseconds(500)); p.set_exception(boost::make_exception_ptr(3.5)); }
void func5(boost::promise<void> p) { boost::this_thread::sleep_for(boost::chrono::milliseconds(500)); p.set_value(); }
void func() { p.set_value_at_thread_exit(i); i = 4; }
void func3(boost::promise<int&> p) { boost::this_thread::sleep_for(boost::chrono::milliseconds(500)); j = 5; p.set_value(j); }
void func5(boost::promise<void> p) { boost::this_thread::sleep_for(ms(500)); p.set_value(); }
void func3(boost::promise<int&> p) { boost::this_thread::sleep_for(ms(500)); j = 5; p.set_value(j); }
void func() { boost::csbl::unique_ptr<int> uptr(new int(5)); p.set_value_at_thread_exit(boost::move(uptr)); }
void func2() { p2.set_value_at_thread_exit(boost::csbl::make_unique<int>(5)); }
layer_consumer() : first_frame_reported_(false) { first_frame_available_ = first_frame_promise_.get_future(); frame_buffer_.set_capacity(2); }