GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - jgaa/modern_async_cpp_example: Just some example code from a lecture about modern async C++

BranchesTags
Open more actions menu

Latest commit

 

History

8 Commits
8 Commits

Folders and files

NameName
Last commit message
Last commit date
CMakeLists.txt
CMakeLists.txt
 
 
async.cpp
async.cpp
 
 
modern.cpp
modern.cpp
 
 
readme.txt
readme.txt
 
 
traditional.cpp
traditional.cpp
 
 

Repository files navigation

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.

About

Just some example code from a lecture about modern async C++

Topics

asioc-plus-pluscoroutinesexample-code

Resources

Readme
Activity

Stars

36 stars

Watchers

8 watching

Forks

7 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.