Skip to content

Instantly share code, notes, and snippets.

#include <iostream>
#include <boost/asio/io_context.hpp>
#include <boost/asio/experimental/co_spawn.hpp>
#include <boost/asio/experimental/detached.hpp>
#include <boost/beast/experimental/test/stream.hpp>
#include <art/detached_task.hpp>
#include <art/sync/channel.hpp>
#include <act/stream.hpp>
#include <benchmark/benchmark.h>
@jamboree
jamboree / coro-performance.cpp
Created September 20, 2017 03:04
Compare Boost.Coroutine2/CO2/CoroutineTS
// Copyright Oliver Kowalke 2014.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <cstdlib>
#include <iostream>
#include <stdexcept>
#include <string>
@jamboree
jamboree / suspend.hpp
Created August 29, 2017 05:10
suspend awaiter for Coroutine-TS
namespace stdex = std::experimental;
class unique_coroutine
{
stdex::coroutine_handle<> _h;
public:
explicit unique_coroutine(stdex::coroutine_handle<> h) noexcept : _h(h) {}
unique_coroutine(unique_coroutine&& other) noexcept : _h(other._h) { other._h = nullptr; }
#include <iostream>
#include <co2/coroutine.hpp>
#include <boost/asio/io_service.hpp>
#include <boost/asio/steady_timer.hpp>
#include <boost/asio/ip/udp.hpp>
#include <act/timer.hpp>
#include <act/socket.hpp>
namespace asio = boost::asio;
#include <iostream>
#include <thread>
#include <co2/task.hpp>
#include <co2/blocking.hpp>
#include <boost/asio/io_service.hpp>
#include <deque>
#include <ppl.h>
#include <tbb/task_group.h>
struct lifo_queue
@jamboree
jamboree / Make Typedef Great Again.md
Last active December 25, 2016 09:37
Make Typedef Great Again

Make Typedef Great Again

Typedef declaration is superseded by type alias declaration since C++11, its legend seems to come to the end. However, we can make typedef much more useful than it is, by allowing it to be used in acompany with variable declarations (including parameters and return types) and base-clause in a class declaration.

The problem

Everyone who loves templates are likely to face a problem - the name of the type being specified is too long that we don't want to spell it out twice! Although we have type alias, but unfortunately in many cases, it cannot be used at the first place and we are forced to spell the irritating names at least twice if we have to refer to the type more than once. Here are some examples:

#include <thread>
#include <iostream>
#include <atomic>
#include <boost/asio/io_service.hpp>
#include <boost/asio/steady_timer.hpp>
#include <boost/asio/ip/udp.hpp>
#include <boost/asio/use_future.hpp>
#include <boost/utility/string_ref.hpp>
namespace asio = boost::asio;
@jamboree
jamboree / object transition.md
Last active April 28, 2020 13:31
Practical object transition for C++
Document Number: P0XXXR0
Date: 2016-xx-xx
Reply-to: tongari95@gmail.com
Audience: EWG

Practical object transition for C++

1. Introduction

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title><%= documentTitle %></title>
<style>
body{
margin: 0 auto;
font-family: Georgia, Palatino, serif;
color: #444444;
Document Number: P0XXXR0
Date: 2016-xx-xx
Reply-to: tongari95@gmail.com
Audience: EWG

Uniform designated initializers and arguments for C++

1. Introduction