This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef EXPERIMENTAL_SIMPLE_GENERATOR | |
# define EXPERIMENTAL_SIMPLE_GENERATOR | |
#include <experimental/coroutine> | |
namespace std::experimental { | |
template <typename T> struct generator { | |
struct promise_type { | |
T current_value; | |
suspend_always yield_value(T value) { | |
this->current_value = value; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <typename SyncReadStream, typename DynamicBuffer> | |
auto async_read_until(SyncReadStream &s, DynamicBuffer &&buffers, | |
string delim) { | |
struct Awaiter { | |
SyncReadStream &s; | |
DynamicBuffer &&buffers; | |
string delim; | |
std::error_code ec; | |
size_t sz; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Emulating cps call using LLVM Coroutines | |
; RUN: opt coro-cps.ll -O2 -enable-coroutines -S | |
define void @f(i32 %arg) { | |
entry: | |
%bar.ret.addr = alloca i32 | |
%id = call token @llvm.coro.id(i32 0, i8* null, i8* null, i8* null) | |
%size = call i32 @llvm.coro.size.i32() | |
%alloc = call i8* @malloc(i32 %size) | |
%hdl = call noalias i8* @llvm.coro.begin(token %id, i8* %alloc) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef RECURSIVE_recursive_generator | |
#define RECURSIVE_recursive_generator | |
#include <experimental/coroutine> | |
// This class implements delegating (potentially recursive) recursive_generator. | |
// It supports two kind of yield expressions: | |
// | |
// co_yield V; | |
// co_yield G_of_T; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <exception> | |
#include <experimental/coroutine> | |
#include <tuple> | |
#include <mutex> | |
#include <condition_variable> | |
#include <cstdlib> | |
struct monostate {}; |