Code Monkey home page Code Monkey logo

asio-with-coroutines's Introduction

Boost ASIO with the Coroutines TS

This project is an experiment of mine to see how difficult it is to wrap existing asynchronous APIs using the new Coroutines TS. The project implements a simple asynchronous echo server in two ways. The first way is by using ASIO directly, and is very similar to the echo server example provided in the boost documentation. The second way is by writing a small amount of boilerplate to wrap the ASIO interface, and then simply writing some coroutines for the echo server.

Requirements

To compile this code, you will need clang 5, the corresponding libc++, and boost. If you are using archlinux and pacaur, you can get all three of these with:

pacaur -S clang boost libc++

The project can then be built with make, make opt or make debug.

Project Layout

The conventional implementation using asio is in classic_asio.cc. The coroutines implementation is broken into two parts: coroutine_wrappers.{h,cc} contain the boilerplate for converting the API to coroutines, and coroutines_asio.cc contains the echo server.

The boilerplate code in coroutine_wrappers does not cater specifically to the echo server use case, which is why I have separated it from the echo server implementation.

asio-with-coroutines's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.