Coder Social home page Coder Social logo

modern_async_cpp_example's Introduction

This mini-project consists of some examples I wrote for a
30 minutes mini-lecture about modern async C++.

In order to put the modern code in perspective, I implemented
the same algorithm three times. First, "traditional.cpp" using
blocking IO. Then, in "async.cpp" I show how most people
would implement it today, using scattered methods and callbacks.
And last in "modern.cpp", I show how elegantly it can be done
with recent versions of boost::asio, using coroutines in stead
of callbacks. The code is async, but it looks just as simple as
traditional blocking code. As an extra bonus, the stack is
intact, so if your program crash, you will have much more
accurate information than in the async case.

The code is very simple; it resolves a host-name, loops over
the received IP numbers until it connects (or fails to connect
to any of them). When connected, it sends a minimalistic
HTTP request to the address, and prints the server-response
directly to the standard output.

The code is compiled with clang 3.5 and g++ 4.9.1

I put this code in the public domain.

Jarle (jgaa) Aase, December 2014.

modern_async_cpp_example's People

Contributors

jgaa avatar

Stargazers

 avatar

Watchers

 avatar  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.