我想使用boost光纤来完成与外部服务的异步通信。我使用一组承诺和未来为每个单独的光纤在一个单独的读取器光纤上调用,以唤醒等待未来的始发光纤。
问题是我无法弄清楚lambda函数的类型。我尝试使用std :: function和std :: bind。但我没有设法找出正确的类型。
回调采用以下结构:
let mix = require('laravel-mix');
/*
|--------------------------------------------------------------------------
| Mix Asset Management
|--------------------------------------------------------------------------
|
| Mix provides a clean, fluent API for defining some Webpack build steps
| for your Laravel application. By default, we are compiling the Sass
| file for the application as well as bundling up all the JS files.
|
*/
mix.js('resources/assets/js/app.js', 'public/js')
.sass('resources/assets/sass/app.scss', 'public/css');
适用于POD,例如:
struct AsyncClientCall {
std::string response;
bool status; // Storage for the status of the RPC upon completion.
// what is the proper type for this
std::function<void()> callback;
};
但它没有boost :: fibers :: promise,因为没有复制构造函数:
asyncCall->callback = [i = msg] () mutable {
std::cout << "release the lock: " << i << std::endl;
};
然而lambda本身没有问题,因为这样可以正常工作
asyncCall->callback = [p = std::move(promiseRsp)] () mutable {
p.set_value();
};
所以我的问题是如果我想使用光纤之间的同步承诺
,如何正确解决这个问题