本文整理汇总了C++中qi::Promise::future方法的典型用法代码示例。如果您正苦于以下问题:C++ Promise::future方法的具体用法?C++ Promise::future怎么用?C++ Promise::future使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qi::Promise
的用法示例。
在下文中一共展示了Promise::future方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onSDEventConnected
void ServiceDirectoryClient::onSDEventConnected(qi::Future<SignalLink> future,
qi::Promise<void> promise, bool isAdd)
{
if (promise.future().isFinished()) {
return;
}
if (future.hasError())
{
qi::Future<void> fdc = onSocketDisconnected(future.error());
fdc.connect(&qi::Promise<void>::setError, promise, future.error());
return;
}
bool ready = false;
{
boost::mutex::scoped_lock lock(_mutex);
if (isAdd)
_addSignalLink = future.value();
else
_removeSignalLink = future.value();
ready = _addSignalLink && _removeSignalLink;
}
if (ready)
{
promise.setValue(0);
connected();
}
}
示例2: log
void log(const qi::LogLevel,
const qi::Clock::time_point,
const qi::SystemClock::time_point,
const char*,
const char*,
const char*,
const char*,
int) {
start.future().wait();
if (++count == MAX)
finished.setValue(0);
}
示例3:
TEST(QiApplicationSession, defaultConnect)
{
ASSERT_FALSE(_app->session()->isConnected());
_app->start();
ASSERT_TRUE(_app->session()->isConnected());
ASSERT_EQ(_url, _app->session()->url());
ASSERT_FALSE(_stopped);
_sd.close();
_sync.future().wait();
ASSERT_TRUE(_stopped);
EXPECT_THROW(_app->session()->connect("ftp://invalidurl:42"),
qi::FutureUserException);
ASSERT_FALSE(_app->session()->isConnected());
}
示例4:
TEST(Test, Recurse)
{
payload = qi::Promise<bool>();
TestSessionPair p1;
TestSessionPair p2(p1);
qi::DynamicObjectBuilder ob1, ob2;
ob1.advertiseMethod("onFire1", &onFire1);
ob2.advertiseMethod("onFire2", &onFire2);
qi::AnyObject oserver1(ob1.object()), oserver2(ob2.object());
unsigned int nbServices = TestMode::getTestMode() == TestMode::Mode_Nightmare ? 2 : 1;
// Two objects with a fire event and a onFire method.
ASSERT_NO_THROW(p1.server()->registerService("coin1", oserver1).hasValue(2000));
ASSERT_NO_THROW(p2.server()->registerService("coin2", oserver2).hasValue(2000));
EXPECT_EQ(nbServices, p1.server()->services(qi::Session::ServiceLocality_Local).value().size());
EXPECT_EQ(nbServices, p2.server()->services(qi::Session::ServiceLocality_Local).value().size());
oclient1 = p2.client()->service("coin1");
oclient2 = p1.client()->service("coin2");
#ifdef WIN32
int niter = 1000;
#else
int niter = 1000;
#endif
if (TestMode::getTestMode() == TestMode::Mode_SSL)
{
niter /= 100;
}
if (getenv("VALGRIND"))
{
std::cerr << "Valgrind detected, reducing iteration count" << std::endl;
niter = 50;
}
oclient1.call<void>("onFire1", niter);
ASSERT_NO_THROW(payload.future().hasValue(2000));
oclient1.reset();
oclient2.reset();
}