mirror of
https://github.com/Naios/continuable.git
synced 2026-10-28 18:07:24 +08:00
Fix the examples after the r-value qualification in 84ca172caa3
This commit is contained in:
parent
84ca172caa
commit
616b68c008
@ -29,14 +29,14 @@ void creating_continuables() {
|
|||||||
auto void_continuable = cti::make_continuable<void>([](auto&& callback) {
|
auto void_continuable = cti::make_continuable<void>([](auto&& callback) {
|
||||||
// ^^^^
|
// ^^^^
|
||||||
|
|
||||||
// Call the callback later when you have finished your work
|
// Call the promise later when you have finished your work
|
||||||
callback();
|
callback.set_value();
|
||||||
});
|
});
|
||||||
|
|
||||||
auto str_continuable =
|
auto str_continuable =
|
||||||
cti::make_continuable<std::string>([](auto&& callback) {
|
cti::make_continuable<std::string>([](auto&& callback) {
|
||||||
// ^^^^^^^^^^^
|
// ^^^^^^^^^^^
|
||||||
callback("Hello, World!");
|
callback.set_value("Hello, World!");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,8 +99,10 @@ void chaining_continuables() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto http_request(std::string /*url*/) {
|
auto http_request(std::string /*url*/) {
|
||||||
return cti::make_continuable<std::string>(
|
return cti::make_continuable<std::string>([](auto&& callback) {
|
||||||
[](auto&& callback) { callback("<html>...</html>"); });
|
// ...
|
||||||
|
callback.set_value("<html>...</html>");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void connecting_continuables() {
|
void connecting_continuables() {
|
||||||
|
|||||||
@ -23,19 +23,27 @@
|
|||||||
#include "continuable/continuable.hpp"
|
#include "continuable/continuable.hpp"
|
||||||
|
|
||||||
cti::continuable<std::string> http_request(std::string /*url*/) {
|
cti::continuable<std::string> http_request(std::string /*url*/) {
|
||||||
return cti::make_continuable<std::string>(
|
return cti::make_continuable<std::string>([](auto&& callback) {
|
||||||
[](auto&& callback) { callback("<html>...</html>"); });
|
// ...
|
||||||
|
callback.set_value("<html>...</html>");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ResultSet {};
|
struct ResultSet {};
|
||||||
struct Buffer {};
|
struct Buffer {};
|
||||||
|
|
||||||
cti::continuable<ResultSet> mysql_query(std::string /*url*/) {
|
cti::continuable<ResultSet> mysql_query(std::string /*url*/) {
|
||||||
return cti::make_continuable([](auto&& callback) { callback(ResultSet{}); });
|
return cti::make_continuable([](auto&& callback) {
|
||||||
|
// ...
|
||||||
|
callback.set_value(ResultSet{});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
cti::continuable<Buffer> read_file(std::string /*url*/) {
|
cti::continuable<Buffer> read_file(std::string /*url*/) {
|
||||||
return cti::make_continuable([](auto&& callback) { callback(Buffer{}); });
|
return cti::make_continuable([](auto&& callback) {
|
||||||
|
// ...
|
||||||
|
callback.set_value(Buffer{});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
struct a {
|
struct a {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user