All Projects → whatisaphone → Genawaiter

whatisaphone / Genawaiter

Stackless generators on stable Rust.

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to Genawaiter

Swiftcoroutine
Swift coroutines for iOS, macOS and Linux.
Stars: ✭ 690 (+162.36%)
Mutual labels:  async, coroutine, await
Coobjc
coobjc provides coroutine support for Objective-C and Swift. We added await method、generator and actor model like C#、Javascript and Kotlin. For convenience, we added coroutine categories for some Foundation and UIKit API in cokit framework like NSFileManager, JSON, NSData, UIImage etc. We also add tuple support in coobjc.
Stars: ✭ 3,921 (+1390.87%)
Mutual labels:  coroutine, await, generator
Async
Easily run code asynchronously
Stars: ✭ 1,983 (+653.99%)
Mutual labels:  async, await
Aint Queue
🚀 An async-queue library built on top of swoole, flexable multi-consumer, coroutine supported. 基于 Swoole 的一个异步队列库,可弹性伸缩的工作进程池,工作进程协程支持。
Stars: ✭ 143 (-45.63%)
Mutual labels:  async, coroutine
Minicoro
Single header asymmetric stackful cross-platform coroutine library in pure C.
Stars: ✭ 164 (-37.64%)
Mutual labels:  async, coroutine
Micro
Asynchronous HTTP microservices
Stars: ✭ 9,987 (+3697.34%)
Mutual labels:  async, await
Rubico
[a]synchronous functional programming
Stars: ✭ 133 (-49.43%)
Mutual labels:  async, generator
Hydra
⚡️ Lightweight full-featured Promises, Async & Await Library in Swift
Stars: ✭ 1,954 (+642.97%)
Mutual labels:  async, await
Async Retry
Retrying made simple, easy and async
Stars: ✭ 1,262 (+379.85%)
Mutual labels:  async, await
Asyncex
A helper library for async/await.
Stars: ✭ 2,794 (+962.36%)
Mutual labels:  async, await
Taskbuilder.fs
F# computation expression builder for System.Threading.Tasks
Stars: ✭ 217 (-17.49%)
Mutual labels:  async, await
Coerce Rs
Coerce - an asynchronous (async/await) Actor runtime and cluster framework for Rust
Stars: ✭ 231 (-12.17%)
Mutual labels:  async, await
Swimmer
🏊 Swimmer - An async task pooling and throttling utility for JS
Stars: ✭ 94 (-64.26%)
Mutual labels:  async, await
Alecrimasynckit
async and await for Swift.
Stars: ✭ 89 (-66.16%)
Mutual labels:  async, await
Mobc
A generic connection pool for Rust with async/await support
Stars: ✭ 141 (-46.39%)
Mutual labels:  async, await
Magpie
🐦 Successor of my monkey Interpreter(support for class, linq, sql, net, http, fmt, json and A realtime syntax highlighting REPL).
Stars: ✭ 88 (-66.54%)
Mutual labels:  async, await
Unityfx.async
Asynchronous operations (promises) for Unity3d.
Stars: ✭ 143 (-45.63%)
Mutual labels:  async, coroutine
ProtoPromise
Robust and efficient library for management of asynchronous operations in C#/.Net.
Stars: ✭ 20 (-92.4%)
Mutual labels:  await, coroutine
Emacs Async Await
Async/Await for Emacs
Stars: ✭ 47 (-82.13%)
Mutual labels:  async, await
Unityasync
Task and Async Utility Package for Unity. Start co-routines from anywhere.
Stars: ✭ 58 (-77.95%)
Mutual labels:  async, coroutine

genawaiter

crate-badge docs-badge ci-badge

This crate implements stackless generators (aka coroutines) in stable Rust. Instead of using yield, which won't be stabilized anytime soon, you use async/await, which is stable today.

Features:

  • supports resume arguments and completion values
  • supports async generators (e.g., Streams)
  • allocation-free
  • no runtime dependencies
    • no compile-time dependencies either, with default-features = false
  • built on top of standard language constructs, which means there are no platform-specific shenanigans

Example:

let odd_numbers_less_than_ten = gen!({
    let mut n = 1;
    while n < 10 {
        yield_!(n); // Suspend a function at any point with a value.
        n += 2;
    }
});

// Generators can be used as ordinary iterators.
for num in odd_numbers_less_than_ten {
    println!("{}", num);
}

Result:

1
3
5
7
9

And here is the same generator, this time without macros. This is how you do things with default-features = false (which eliminates the proc macro dependencies).

let odd_numbers_less_than_ten = Gen::new(|co| async move {
    let mut n = 1;
    while n < 10 {
        co.yield_(n).await;
        n += 2;
    }
});

See the docs for more.

Development

Install prerequisites

Install the pre-commit hook

pre-commit install

This installs a Git hook that runs a quick sanity check before every commit.

Run the app

cargo run

Run the tests

cargo test
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].