本文整理汇总了C++中Future::getPromise方法的典型用法代码示例。如果您正苦于以下问题:C++ Future::getPromise方法的具体用法?C++ Future::getPromise怎么用?C++ Future::getPromise使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Future
的用法示例。
在下文中一共展示了Future::getPromise方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: bld
Future<IClient::Result> ClientWS::callAsync(ConstStrA method, JSON::ConstValue params, JSON::ConstValue context) {
Synchronized<FastLockR> _(lock);
if (params == null) {
params = jsonFactory->array();
} else if (!params->isArray()) {
params = JSON::Container(jsonFactory->array()).add(params);
}
JSON::Builder bld(jsonFactory);
natural thisid = idcounter++;
JSON::Builder::CObject req = bld("id",thisid)
.container()
("method",method)
("params",params);
if (context != null) {
req("context",context);
}
ConstStrA msg = jsonFactory->toString(*req);
Future<Result> f;
sendTextMessage(msg);
waitingResults.insert(thisid,f.getPromise());
return f;
}
示例2: operator
virtual Future<Response> operator()(const Request &req) const throw() {
Future<Response> out;
try {
WeakRefPtr<IPeer> peer = req.peer;
if (peer == null) throw CanceledException(THISLOCATION);
WeakRefPtr<IDispatcher> dispptr(req.dispatcher);
jsonsrv::RpcRequest oldreq;
oldreq.args = static_cast<const JSON::Value &>(req.params);
oldreq.context = static_cast<const JSON::Value &>(req.context);
oldreq.functionName = req.methodName.getStringA();
oldreq.httpRequest = peer->getHttpRequest();
oldreq.id = req.id.getStringA();
oldreq.idnode = static_cast<const JSON::Value &>(req.id);
oldreq.jsonFactory = req.json.factory;
oldreq.serverStub = dispptr->getIfcPtr<jsonsrv::IJsonRpc>();
JSON::Value oldres = (mptr)(&oldreq);
out.getPromise().resolve(Response(oldres, oldreq.contextOut, oldreq.logOutput));
} catch (...) {
out.getPromise().rejectInCatch();
}
return out;
}
示例3:
Future<void> WebSocketsClient::onReconnect() {
Future<void> r;
queuedMsgs.push(r.getPromise());
return r;
}