mirror of
https://github.com/Naios/continuable.git
synced 2025-12-06 16:56:44 +08:00
Readd unique_continuable
This commit is contained in:
parent
22c9ee01d4
commit
a685d9234a
@ -63,14 +63,14 @@ using continuable = typename detail::trait_of<
|
||||
Args...
|
||||
>::continuable;
|
||||
|
||||
/// Defines a copyable callback type which uses the
|
||||
/// function2 backend for the continuable type erasure.
|
||||
/// Defines a non-copyable continuation type which uses the
|
||||
/// function2 backend for type erasure.
|
||||
///
|
||||
/// Usable like: `callback<int, float>`
|
||||
// template <typename... Args>
|
||||
// using promise = typename detail::trait_of<
|
||||
// Args...
|
||||
// >::promise;
|
||||
/// Usable like: `unique_continuable<int, float>`
|
||||
template <typename... Args>
|
||||
using unique_continuable = typename detail::unique_trait_of<
|
||||
Args...
|
||||
>::continuable;
|
||||
|
||||
/// Defines a non-copyable promise type which using the
|
||||
/// function2 backend for type erasure.
|
||||
@ -81,15 +81,6 @@ using promise = typename detail::unique_trait_of<
|
||||
Args...
|
||||
>::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 sink
|
||||
|
||||
|
||||
@ -35,9 +35,7 @@ static cti::continuable<std::string> http_request(std::string url) {
|
||||
};
|
||||
}
|
||||
|
||||
/*
|
||||
// TODO Fix this
|
||||
static cti::continuable<std::string> http_request(std::string url) {
|
||||
static cti::continuable<std::string> http_request3(std::string url) {
|
||||
return [url = std::move(url)](auto promise) {
|
||||
if (false) {
|
||||
promise.set_value("");
|
||||
@ -46,7 +44,6 @@ static cti::continuable<std::string> http_request(std::string url) {
|
||||
promise.set_exception(std::error_condition{});
|
||||
};
|
||||
}
|
||||
*/
|
||||
|
||||
static auto http_request2(std::string url) {
|
||||
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;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user