Created
May 27, 2019 06:31
-
-
Save suneo3476/c2fedb2632a5ca725654d25a79ab37b0 to your computer and use it in GitHub Desktop.
非同期通信内で非同期通信を発行すると怒られるのなぜ?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cpprest/http_client.h> | |
using namespace web::http; | |
// ... | |
void execApi(){ | |
// ... | |
http_client cli(url,config); | |
http_request req(methods::POST); | |
// 最初の非同期通信 | |
cli.request(req).then([](http_response res) | |
{ | |
// 応答があったら次へ | |
return result; | |
}).then([](auto result) | |
{ | |
http_client cli(url,config); | |
http_request req(methods::GET); | |
// ポーリング | |
while(1){ | |
// 怒られない書き方(同期的) | |
http_response res = cli.request(req).get(); | |
// 怒られる書き方(非同期的) | |
cli.request(req).then([](http_response res){ | |
// ... | |
}).wait(); | |
} | |
}).wait(); | |
} | |
/* ビルド失敗時のメッセージ内容 | |
ppltasks.h(394,26): error C2672: '_VoidReturnTypeHelper': 一致するオーバーロードされた関数が見つかりませんでした。 | |
ppltasks.h(428): message : コンパイル対象の クラス テンプレート インスタンス化 'Concurrency::details::_FunctionTypeTraits<_Function,_ReturnType>' のリファレンスを確認してください | |
ppltasks.h(428): message : with | |
ppltasks.h(428): message : [ | |
ppltasks.h(428): message : _Function=execSpeech2TextApi::<lambda_63188b53ed9b26640583f75bb73a5161>, | |
ppltasks.h(428): message : _ReturnType=void | |
ppltasks.h(428): message : ] | |
double_async_request.cpp(33): message : コンパイル対象の クラス テンプレート インスタンス化 'Concurrency::details::_ContinuationTypeTraits<execApi::<lambda_*************************>,void>' のリファレンスを確認してください | |
ppltasks.h(4147): message : クラス テンプレート メンバー関数 'details::_ContinuationTypeTraits<_Function,void>::_TaskOfType Concurrency::task<void>::then(const _Function &,Concurrency::task_options) const' のコンパイル中 | |
ppltasks.h(394,1): error C2893: 関数テンプレート 'unknown-type Concurrency::details::_VoidReturnTypeHelper(_Function,int,int)' の特定に失敗しました | |
ppltasks.h(394,1): message : 次のテンプレート引数で: | |
ppltasks.h(394,1): message : '_Function=_Ty') | |
ppltasks.h(428,19): error C2955: 'Concurrency::details::_TaskTypeTraits': クラス テンプレート を使用するには テンプレート 引数リストが必要です | |
ppltasks.h(343): message : 'Concurrency::details::_TaskTypeTraits' の宣言を確認してください | |
ppltasks.h(432,4): error C2955: 'Concurrency::details::_StdFunctionTypeHelper': クラス テンプレート を使用するには テンプレート 引数リストが必要です | |
ppltasks.h(414): message : 'Concurrency::details::_StdFunctionTypeHelper' の宣言を確認してください | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment