#await #framework #gate #runtime #webassembly

gain

Async/await-based framework for programs targetting Gate runtime (wasm32 targets)

7 releases (4 breaking)

0.5.0 Dec 27, 2021
0.4.1 Jun 12, 2021
0.4.0 Mar 6, 2021
0.3.0 Nov 6, 2020
0.1.0 Dec 2, 2018

#5 in #gate

Download history 7/week @ 2022-11-27 10/week @ 2022-12-04 18/week @ 2022-12-11 13/week @ 2022-12-18 12/week @ 2022-12-25 6/week @ 2023-01-01 11/week @ 2023-01-08 9/week @ 2023-01-15 17/week @ 2023-01-22 35/week @ 2023-01-29 53/week @ 2023-02-05 38/week @ 2023-02-12 41/week @ 2023-02-19 15/week @ 2023-03-05 4/week @ 2023-03-12

60 downloads per month
Used in 3 crates

MIT license

84KB
2.5K SLoC

Gate interface

Asynchronous execution

The task module provides a framework for spawning and running asynchronous tasks.

A typical program runs a single top-level task:

use gain::task::{block_on, spawn};

fn main() {
    block_on(async {
        spawn(concurrent_work());
        do_something().await;
    })
}

async fn concurrent_work() {
    do_stuff().await;
}

Concurrency is achieved by spawning more tasks. The program exits when the top-level task returns.

Service APIs

The catalog, identity, origin, peer and peerindex modules provide access to the built-in Gate services.

Common I/O stream types are defined in the stream module.

Service implementation

Additional service bindings can be implemented using the service module.

Dependencies

~200KB