All Projects → luncliff → Coroutine

luncliff / Coroutine

Licence: cc-by-4.0
C++ 20 Coroutines in Action (Helpers + Test Code Examples)

Programming Languages

cpp
1120 projects

Projects that are alternatives of or similar to Coroutine

Swiftcoroutine
Swift coroutines for iOS, macOS and Linux.
Stars: ✭ 690 (+163.36%)
Mutual labels:  coroutines, coroutine
Unityfx.async
Asynchronous operations (promises) for Unity3d.
Stars: ✭ 143 (-45.42%)
Mutual labels:  coroutines, coroutine
Tascalate Javaflow
Continuations / CoRoutines for Java 1.5 - 11, build tools, CDI support. This project is based on completely re-worked Apache Jakarta Commons JavaFlow library.
Stars: ✭ 51 (-80.53%)
Mutual labels:  coroutines, coroutine
Concurrencpp
Modern concurrency for C++. Tasks, executors, timers and C++20 coroutines to rule them all
Stars: ✭ 340 (+29.77%)
Mutual labels:  coroutines, coroutine
Webassembly Examples
From Simple To Complex. A complete collection of webassembly examples.
Stars: ✭ 177 (-32.44%)
Mutual labels:  clang, examples
Kotlin Coroutines Android Examples
Learn Kotlin Coroutines for Android by Examples. Learn how to use Kotlin Coroutines for Android App Development.
Stars: ✭ 572 (+118.32%)
Mutual labels:  coroutines, examples
Fiber Ext
stackful-coroutines for PHP
Stars: ✭ 142 (-45.8%)
Mutual labels:  coroutines, coroutine
Libfiber
The high performance coroutine library for Linux/FreeBSD/MacOS/Windows, supporting select/poll/epoll/kqueue/iocp/windows GUI
Stars: ✭ 519 (+98.09%)
Mutual labels:  coroutines, coroutine
Cppcoro
A library of C++ coroutine abstractions for the coroutines TS
Stars: ✭ 2,118 (+708.4%)
Mutual labels:  clang, coroutines
Mvvmtemplate
An Android Template with MVVM and Clean Architecture
Stars: ✭ 182 (-30.53%)
Mutual labels:  coroutines, coroutine
Co
Art of C++. Flag, logging, unit-test, json, go-style coroutine and more.
Stars: ✭ 2,264 (+764.12%)
Mutual labels:  coroutine, coroutines
Jacob
A lightweight library to provide coroutines in Java
Stars: ✭ 14 (-94.66%)
Mutual labels:  coroutines, coroutine
Flow
C# co-routine Kernel for .Net. Includes Futures, Barriers, Triggers, Timers and Groups. Gamasutra article provides extra documentation.
Stars: ✭ 59 (-77.48%)
Mutual labels:  coroutines, coroutine
Minicoro
Single header asymmetric stackful cross-platform coroutine library in pure C.
Stars: ✭ 164 (-37.4%)
Mutual labels:  coroutines, coroutine
ProtoPromise
Robust and efficient library for management of asynchronous operations in C#/.Net.
Stars: ✭ 20 (-92.37%)
Mutual labels:  coroutines, coroutine
DeezerClone
This Application using Dagger Hilt, Coroutines, Flow, Jetpack (Room, ViewModel, LiveData),Navigation based on MVVM architecture.
Stars: ✭ 81 (-69.08%)
Mutual labels:  coroutines, coroutine
examples
Repository of RobotPy example projects
Stars: ✭ 25 (-90.46%)
Mutual labels:  examples
Rpcx Examples
examples for the latest rpcx
Stars: ✭ 256 (-2.29%)
Mutual labels:  examples
modern-android
Modern Android Project Skeleton
Stars: ✭ 17 (-93.51%)
Mutual labels:  coroutines
reflective-rapidjson
Code generator for serializing/deserializing C++ objects to/from JSON using Clang and RapidJSON
Stars: ✭ 26 (-90.08%)
Mutual labels:  clang

coroutine

C++ 20 Coroutines in Action

Build Status Build status Build Status Codacy Badge

Purpose of this repository

  • Help understanding of the C++ Coroutines
  • Provide meaningful design example with the feature

In that perspective, the library will be maintained as small as possible. Have fun with them. And try your own coroutines!

If you are looking for another materials, visit the MattPD's collection!

  • Start with the GitHub Pages :)
    You will visit the test/ and interface/ folder while reading the docs.
  • This repository has some custom(and partial) implementation for the C++ Coroutines in the <coroutine/frame.h>.
    It can be activated with macro USE_PORTABLE_COROUTINE_HANDLE

Pre-requisite

The installation of this library will install it together. All other required modules for build/test will be placed in external/.

Tool Support

  • CMake
    • msvc
    • clang-cl: Works with VC++ headers
    • clang: Linux
    • AppleClang: Mac

Known Issues

TBA

How To

Setup

Simply clone and initialize submodules recursively :)

git clone https://github.com/luncliff/coroutine
pushd coroutine
  git submodule update --init --recursive
popd

Test

Exploring test(example) codes will be helpful. The library uses CTest for its test. AppVeyor & Travis CI build log will show the execution of them.

Import

If you want some tool support, please let me know. I'm willing to learn about it.

CMake 3.12+

Expect there is a higher CMake project which uses this library.

The library exports 3 targets.

  • coroutine_portable
    • <coroutine/frame.h>
    • <coroutine/return.h>
    • <coroutine/channel.hpp>
  • coroutine_system
    • requires: coroutine_portable
    • <coroutine/windows.h>
    • <coroutine/linux.h>
    • <coroutine/unix.h>
    • <coroutine/pthread.h>
  • coroutine_net
    • requires: coroutine_system
    • <coroutine/net.h>
cmake_minimum_required(VERSION 3.12)

find_package(coroutine CONFIG REQUIRED)
# or add_subdirectory(coroutine) if you want to be simple

target_link_libraries(main
PUBLIC
    coroutine_portable
    coroutine_system
    coroutine_net
)

Developer Note

Interface

Portable

To support multiple compilers, this library defines its own header, <coroutine/frame.h>. This might lead to conflict with existing library (libc++ and VC++).
If there is a collision(build issue), please make an issue in this repo so I can fix it.

// This header includes/overrides <experimental/coroutine>
#include <coroutine/frame.h>

Utility types are in the following headers. With the macro USE_EXPERIMENTAL_COROUTINE, you can enforce <experimental/coroutine> instead of <coroutine/frame.h>

// return/promise types for coroutine functions
#define USE_EXPERIMENTAL_COROUTINE 
#include <coroutine/return.h> 

Generator is named coro::enumerable here.

For now you can see various description for the concept in C++ conference talks in Youtube.
If you want better implementation or want to see another generators, visit the https://github.com/Quuxplusone/coro :D

// enumerable<T>
#include <coroutine/yield.hpp>

Go language style channel to deliver data between coroutines. It Supports awaitable read/write and select operation are possible.
If you don't know the language, never worry. There was a talk in CppCon

But it is slightly different from that of the Go language because we don't have a built-in scheduler in C++. Furthermore Goroutine is quite different from the C++ Coroutines.
It may not a necessary feature since there are so much of the channel implementation, but you may feel curiosity about it.

// channel<T> with Lockable
#define USE_EXPERIMENTAL_COROUTINE 
#include <coroutine/channel.hpp>

System

The library doesn't provides platform-neutral abstraction.

// #include <gsl/gsl>             // requires ms-gsl
// #include <coroutine/return.h>  // already used by the following headers
#include <coroutine/windows.h>
#include <coroutine/linux.h>
#include <coroutine/unix.h>
#include <coroutine/pthread.h>

Please reference test codes for their usage.

Network

Async I/O with awaitable types for socket operation and poll_net_tasks to multiplex control flow.

#include <coroutine/net.h>

Please reference test codes for its usage.

License

Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].