Readd unique_continuable

This commit is contained in:
Denis Blank 2017-10-03 01:14:53 +02:00
parent 22c9ee01d4
commit a685d9234a
2 changed files with 16 additions and 20 deletions

View File

@ -63,14 +63,14 @@ using continuable = typename detail::trait_of<
Args... Args...
>::continuable; >::continuable;
/// Defines a copyable callback type which uses the /// Defines a non-copyable continuation type which uses the
/// function2 backend for the continuable type erasure. /// function2 backend for type erasure.
/// ///
/// Usable like: `callback<int, float>` /// Usable like: `unique_continuable<int, float>`
// template <typename... Args> template <typename... Args>
// using promise = typename detail::trait_of< using unique_continuable = typename detail::unique_trait_of<
// Args... Args...
// >::promise; >::continuable;
/// Defines a non-copyable promise type which using the /// Defines a non-copyable promise type which using the
/// function2 backend for type erasure. /// function2 backend for type erasure.
@ -81,15 +81,6 @@ using promise = typename detail::unique_trait_of<
Args... Args...
>::promise; >::promise;
/// Defines a non-copyable callback type which uses the
/// function2 backend for the continuable type erasure.
///
/// Usable like: `unique_callback<int, float>`
template <typename... Args>
using unique_callback = typename detail::unique_trait_of<
Args...
>::callback;
// TODO channel // TODO channel
// TODO sink // TODO sink

View File

@ -35,9 +35,7 @@ static cti::continuable<std::string> http_request(std::string url) {
}; };
} }
/* static cti::continuable<std::string> http_request3(std::string url) {
// TODO Fix this
static cti::continuable<std::string> http_request(std::string url) {
return [url = std::move(url)](auto promise) { return [url = std::move(url)](auto promise) {
if (false) { if (false) {
promise.set_value(""); promise.set_value("");
@ -46,7 +44,6 @@ static cti::continuable<std::string> http_request(std::string url) {
promise.set_exception(std::error_condition{}); promise.set_exception(std::error_condition{});
}; };
} }
*/
static auto http_request2(std::string url) { static auto http_request2(std::string url) {
return cti::make_continuable<std::string>( return cti::make_continuable<std::string>(
@ -101,5 +98,13 @@ int main(int, char**) {
// ... // ...
}); });
(http_request("github.com") >> http_request("github.com"))
.then([](std::string, std::string) {
// ...
})
.fail([](std::error_condition) {
// ...
});
return 0; return 0;
} }