🎮 game loop + 🐷 coroutine + 🌯 burrito = 🚀🔥 blazingly synchronous async executor for games 🔥🚀

Overview

🐷 Koryto 🐷

Crates.io Documentation Build Status License

Pronounced like corrito, which is pronounced as if you combined coroutine and burrito, because everyone knows coroutines are burritos in the category of endofunctors.

Game loop focused async executor for all your coroutine needs. Inspired by macroquad's experimental coroutines, the cosync crate, Unity's amazing coroutines, and lastly Godot's coroutines which for a while weren't true burritos.

Pigs eating from a trough

Koryto in Czech means trough, which is the thingy pigs eat from.

Koryto is single threaded and simple. The executor context Koryto expects to be polled every frame with the game's delta time.

Example

// Create a new instance of the executor
let mut ko = Koryto::new();

// Shared state the coroutine sets
let val = Rc::new(RefCell::new(3));
let val_inner = val.clone();

// Start a new coroutine
ko.start(async move {
    wait_seconds(0.5).await;

    *val_inner.borrow_mut() = 9
});

// Delta time obtained from the game loop
let dt = 0.2;

// Poll coroutines as part of the game loop
ko.poll_coroutines(dt);
assert_eq!(*val.borrow(), 3);

ko.poll_coroutines(dt);
assert_eq!(*val.borrow(), 3);

// At this point 0.5 seconds have passed and we observe the coroutine be
// resumed and set the value.
ko.poll_coroutines(dt);
assert_eq!(*val.borrow(), 9);

ko.poll_coroutines(dt);
assert_eq!(*val.borrow(), 9);

FAQ

Is this stable?

No.

Does it work?

Yes, probably ... we have tests.

The source code should be simple enough for anyone to read and understand. There's no 100 000 lines of code like in tokio. Currently koryto does depend on futures in order to implement the select!/join! combinators.

Why not just use cosync when this does exactly the same thing?

Unlike cosync, koryto assumes your application is single threadd, which means your futures don't need to be Send.

This allows you to use Rc for shared state, and also just pass around pointers into the futures without any wrappers.

koryto is also a bit simpler in its API and closer to Macroquad's coroutines, although macroquad's futures also need to be Send.

License

koryto is dual licensed:

You might also like...
Unify your game sources in one place and aquire more of them, using modules made by the community.

Project Black Pearl Unify your game sources in one place by using modules made by the community. What is Project Black Pearl? Project Black Pearl (or

The first compute-centric vector graphic video game
The first compute-centric vector graphic video game

🕹️ Vong This repository contains source code for the first native use of a compute-centric vector graphics video game, inspired by Pong. ✍️ Authors @

A single-threaded polling-based Rust async executor suitable for use in games, embedded systems or WASM.

simple async local executor An Enlightware® software. Overview A single-threaded polling-based executor suitable for use in games, embedded systems or

A single-threaded executor for deferred async code for games.

This crate provides a single-threaded, sequential, parameterized async runtime. In other words, this creates coroutines, specifically targeting video game logic, though cosync is suitable for creating any sequences of directions which take time.

Easy c̵̰͠r̵̛̠ö̴̪s̶̩̒s̵̭̀-t̶̲͝h̶̯̚r̵̺͐e̷̖̽ḁ̴̍d̶̖̔ ȓ̵͙ė̶͎ḟ̴͙e̸̖͛r̶̖͗ë̶̱́ṉ̵̒ĉ̷̥e̷͚̍ s̷̹͌h̷̲̉a̵̭͋r̷̫̊ḭ̵̊n̷̬͂g̵̦̃ f̶̻̊ơ̵̜ṟ̸̈́ R̵̞̋ù̵̺s̷̖̅ţ̸͗!̸̼͋

Rust S̵̓i̸̓n̵̉ I̴n̴f̶e̸r̵n̷a̴l mutability! Howdy, friendly Rust developer! Ever had a value get m̵̯̅ð̶͊v̴̮̾ê̴̼͘d away right under your nose just when

rust_arango enables you to connect with ArangoDB server, access to database, execute AQL query, manage ArangoDB in an easy and intuitive way, both async and plain synchronous code with any HTTP ecosystem you love.

rust_arango enables you to connect with ArangoDB server, access to database, execute AQL query, manage ArangoDB in an easy and intuitive way, both async and plain synchronous code with any HTTP ecosystem you love.

A Rust on-site channel benchmarking helper. Inter-Process (async / busy) & Intra-Process (async single threaded / async multi threaded)

On-Site Rust Channel Benchmarking Helper Deploy on server to determine which public crates are the fastest for communicating in different architecture

An async executor based on the Win32 thread pool API

wae An async executor based on the Win32 thread pool API use futures::channel::oneshot; #[wae::main] async fn main() { let (tx, rx) = oneshot::ch

Async executor for WebAssembly

There are a number of async task executors available in Rust's ecosystem. However, most (if not all?) of them rely on primitives that might not be available or optimal for WebAssembly deployment at the time.

single file, std only, async Rust executor

whorl - A single file, std only, async Rust executor whorl was created to teach you how async executors work in Rust. It is not the fastest executor n

A fast, forbid(unsafe_code), no dependency, async executor

uAsync A fast, forbid(unsafe_code), no dependency, async executor. This crate was made primarily to see if such a thing was pheasable. The executor pe

A blazingly fast rust-based bionic reader for blazingly fast reading within a terminal console 🦀
A blazingly fast rust-based bionic reader for blazingly fast reading within a terminal console 🦀

This Rust-based CLI tool reads text and returns it back in bionic reading format for blazingly fast loading and even faster reading! Bionic reading is

Time-manager of delayed tasks. Like crontab, but synchronous asynchronous tasks are possible, and dynamic add/cancel/remove is supported.
Time-manager of delayed tasks. Like crontab, but synchronous asynchronous tasks are possible, and dynamic add/cancel/remove is supported.

delay-timer Time-manager of delayed tasks. Like crontab, but synchronous asynchronous tasks are possible, and dynamic add/cancel/remove is supported.

OxHTTP is a very simple synchronous HTTP client and server

OxHTTP is a very simple synchronous implementation of HTTP 1.1 in Rust. It provides both a client and a server.

asynchronous and synchronous interfaces and persistence implementations for your OOD architecture

OOD Persistence Asynchronous and synchronous interfaces and persistence implementations for your OOD architecture Installation Add ood_persistence = {

QueingSimulator is an application that can be used to build intuitions about behavior of synchronous request/reply systems

Queueing Simulator QueingSimulator is an application that can be used to build intuitions about behavior of synchronous request/reply systems (such as

A synchronous HTTP server built on hyper.

Astra Astra is a synchronous HTTP server built on top of hyper. use astra::{Body, Response, Server}; fn main() { Server::bind("localhost:3000")

Coroutine I/O for Rust

Coroutine I/O Coroutine scheduling with work-stealing algorithm. WARN: Possibly crash because of TLS inline, check https://github.com/zonyitoo/coio-rs

[no longer maintained] Scalable, coroutine-based, fibers/green-threads for Rust. (aka MIO COroutines).

Documentation mioco Mioco provides green-threads (aka fibers) like eg. Goroutines in Go, for Rust. Status This repo is a complete re-implementation of

Owner
Jakub Arnold
making stuff in Rust
Jakub Arnold
Build database expression type checker and vectorized runtime executor in type-safe Rust

Typed Type Exercise in Rust Build database expression type checker and vectorized runtime executor in type-safe Rust. This project is highly inspired

Andy Lok 89 Dec 27, 2022
API for the creation character based games in Linux.

Console Game Engine for Linux. API for the creation of character based games in Linux. The inspiration came from the olcConsoleGameEngine. This is my

Arjob Mukherjee 4 Sep 27, 2022
An actors library for Rust and Tokio designed to work with async / await message handlers out of the box.

Akt An actors framework for Rust and Tokio. It is heavily inspired by Actix and right now it has very similar look and feel. The main difference is th

Artyom Kozhemiakin 7 Jan 10, 2023
syntax-level async join enabling branching control flow and shared mutable borrow

enjoin enjoin's async join macros operate at the syntax level. It allows you to... break, continue, and return out of async code running in a join for

Wisha W. 15 Apr 16, 2023
Code accompanying the 1 Hour Dive into Async live stream.

1 Hour Async This is the code accompanying the 1 Hour Dive into Async live-stream. The slides are here You can watch the recorded event on YouTube Inc

Herbert 9 Aug 2, 2023
The Computer Language Benchmarks Game: Rust implementations

The Computer Language Benchmarks Game: Rust implementations This is the version I propose to the The Computer Language Benchmarks Game. For regex-dna,

Guillaume P. 69 Jul 11, 2022
The source code that accompanies Hands-on Rust: Effective Learning through 2D Game Development and Play by Herbert Wolverson

Hands-on Rust Source Code This repository contains the source code for the examples found in Hands-on Rust. These are also available from my publisher

Herbert 261 Dec 14, 2022
This experiment shows connecting wasm-bindgen generated code to a good-web-game application.

GWG + wasm-bindgen example This experiment shows connecting wasm-bindgen generated code to a good-web-game application. It uses simple_logger crate to

Tomasz Sterna 1 May 12, 2021
Game Boy Emulator written in Rust, as a way to fully grasp the Rust programming language

Flan's Game Boy Emulator Game Boy Emulator written in Rust, as a way to get hands-on with the Rust programming language, and creating a proper project

Flan 3 Dec 31, 2022
Game development practices with Rust programming language. I want to use different crates for this.

Hazır Oyun Motorlarını Kullanarak Rust Dili Yardımıyla Oyunlar Geliştirmek Rust programlama dilinde oyun geliştirmek için popüler birkaç hazır çatıyı

Burak Selim Senyurt 16 Dec 27, 2022