mirror of
https://github.com/Naios/continuable.git
synced 2025-12-06 08:46:44 +08:00
Update the readme to reflect the recent changes
This commit is contained in:
parent
3963d34a92
commit
d80fe94c0c
51
Readme.md
51
Readme.md
@ -1,20 +1,55 @@
|
||||

|
||||
|
||||
 [](https://travis-ci.org/Naios/continuable) [](https://ci.appveyor.com/project/Naios/continuable/branch/master)  [](https://naios.github.io/continuable/) [](http://melpon.org/wandbox/permlink/xVM2szjDLEge3YLV)
|
||||
[](https://github.com/Naios/continuable/releases/tag/2.0.0) [](https://travis-ci.org/Naios/continuable) [](https://ci.appveyor.com/project/Naios/continuable/branch/master)  [](https://naios.github.io/continuable/) [](http://melpon.org/wandbox/permlink/xVM2szjDLEge3YLV)
|
||||
|
||||
------
|
||||
|
||||
> Async C++14 platform independent continuation chainer providing light and allocation aware futures
|
||||
|
||||
This library provides full feature support of:
|
||||
|
||||
* async continuation chaining using **callbacks** (*then*).
|
||||
* **no enforced type-erasure** which means we need **extremely fewer heap allocations** .
|
||||
* support for **finite logical connections** between continuables through an **all, any or sequence** strategy.
|
||||
* **syntactic sugar** for attaching callbacks to a continuation like partial invocation or tuple unpacking.
|
||||
* lazy async continuation chaining based on **callbacks** (*then*).
|
||||
* **no enforced type-erasure** which means we need **less heap allocations**, strictly following the **"don't pay for what you don't use" ** principle.
|
||||
* support for **connections** between continuables through an **all, any or sequence** strategy.
|
||||
* **error handling** through exceptions or custom types.
|
||||
* **syntactic sugar** for instance: partial invocation, tuple unpacking and executors.
|
||||
|
||||
|
||||
|
||||
## The basics
|
||||
|
||||
|
||||
* Supply a continuable which is invoked lazily upon request:
|
||||
```cpp
|
||||
auto http_request(std::string url) {
|
||||
return cti::make_continuable<std::string>([url = std::move(url)](auto&& promise) {
|
||||
// Perform the actual request through a different library,
|
||||
// resolve the promise upon completion of the task.
|
||||
promise.set_value("<html> ... </html>");
|
||||
});
|
||||
}
|
||||
```
|
||||
* Continue the continuation using `.then(...)` and `.fail(...)`
|
||||
|
||||
```cpp
|
||||
http_request("example.com")
|
||||
.then([] (std::string result) {
|
||||
// Do something...
|
||||
return http_request("example.com/2")
|
||||
})
|
||||
.then([] (std::string result) {
|
||||
// Do more...
|
||||
});
|
||||
```
|
||||
* b
|
||||
```cpp
|
||||
h
|
||||
```
|
||||
* c
|
||||
```cpp
|
||||
h
|
||||
```
|
||||
* d
|
||||
|
||||
|
||||
> **Note:** This library only provides the facility for building asynchronous functions. Thus functions shown in the examples and the documentation like `http_request`, `mysql_query` or `read_file` aren't provided by this library.
|
||||
|
||||
## Table of contents
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user