Elle:基于协程的异步C++开发框架

网友投稿 786 2022-10-12

Elle:基于协程的异步C++开发框架

Elle:基于协程的异步C++开发框架

Elle, the coroutine-based asynchronous C++ development framework

Elle is a collection of libraries, written in modern C++ (C++14). It contains a rich set of highly reusable concepts, algorithms, API wrappers, ...

Elle is split into different specialized sub-libraries to provide elegant ways to approach asynchronism (using coroutines), networking, formatting, serialization, logging, RPCs, etc.

Notes:Elle is under development, used and maintained by Infinit as a core library. APIs, structures and concepts may change over time. You can use it as is but we don't guarantee any API backward compatibility.Elle has a sub-library also called elle, which might change name in a near future.

Example

Here is an example showing an asynchronous HTTP operation in a natural form (no callbacks) and basic jsON serialization.

// Initialize the HTTP Request.elle::reactor::http::Request r("https://en.wikipedia.org/w/api.php", elle::reactor::http::Method::GET);r.query_string({ {"format", "json"}, {"action", "query"}, {"prop", "extracts"}, {"explaintext", ""}, {"exintro", ""}, {"titles", "JSON"}});// Perform the HTTP request and yield until response is available.r.finalize();// Deserialize the json response.std::cout << elle::json::pretty_print(elle::json::read(r)) << std::endl;

Getting Elle

To download the source code and build Elle by yourself, get it from GitHub.

git clone https://github.com/infinit/elle --recursive # Clone elle and its submodules.

Note: If you cloned it using the GitHub "clone" button, do not forget to run git submodule update --init --recursive!

Note: If you forked Elle, you'll also need to fork the following repositories too: drake, dokan, libutp, miniupnp. The reason why is detailed on following GitHub issue.

Structure

As mentioned earlier, Elle is composed of a set of sub-libraries, designed to ease C++ development through robust and flexible implementations, including:

elle: Utilities including serialization, logs, buffer, formatting, ...reactor: An asynchronous framework using a coroutines schedulercryptography: Object-oriented cryptography wrapper around OpenSSLprotocol: Network communication designed to support RPCsdas: Symbol-based introspectionathena: Byzantine environment algorithms (Paxos)service/aws: reactorified AWS API wrapperservice/dropbox: reactorified Dropbox API wrappernbd: A Network Block Device implementation.

How to build Elle (or parts of Elle)

Requirements

gcc (>= 4.9.2) or clang (>= 3.5.0) or mingw (>= 5.3.0).python3 (>= 3.4.0) and pip3.

Build system

Elle uses Drake and has it as a submodule.

How to compile

For a detailed procedure, visit our wiki: How to build.

First you need to install drakes requirements.

sudo pip3 install -r elle/drake/requirements.txt # Install Drake dependencies.

Note: If you don't want Drake dependencies to be installed system-wide, you should consider using virtualenv.

Change directory to elle/_build/ where you can find a generic Drake configuration script.

GNU/Linux

cd elle/_build/linux64./drake //build -j 2 # Build all libraries using 2 jobs.

macOS

cd elle/_build/osx./drake //build -j 2 # Build all libraries using 2 jobs.

Because Elle was designed to be modular, you can build specific parts of Elle by running ./drake ///build:

./drake //src/elle/cryptography/build -j 2 # To build libcryptography and its dependencies../drake //src/elle/reactor/build -j 2 # To build the libreactor and its dependencies../drake //src/elle/protocol/build -j 2 # To build the libprotocol and its dependencies../drake //...

It will result on /lib/libelle_.so and its dependencies on GNU/Linux, /lib/lib.dylib on macOS, ...

Dependencies

Elle depends on a few libraries which are automatically downloaded and built for your system by Drake if needed.

Boost (v1.60.0, patched)PatchELF (v0.9)zlib (v1.2.11)OpenSSL (v1.0.2g)curl (v7.48.0, patched)libarchive (v3.1.2, patched)OpenLDAP (v2.4.44)

List of projects using Elle

Infinit

Wiki

Consult Elle's wiki for more information about Elle.

Maintainers

Website: https://infinit.sh/open-sourceEmail: open+elle@infinit.sh

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:as3 笔记
下一篇:找素数
相关文章

 发表评论

暂时没有评论,来抢沙发吧~