GitXplorerGitXplorer
D

geese_executor

public
2 stars
0 forks
0 issues

Commits

List of commits on branch master.
Unverified
1451303b4223da77b7ffc71cf8a54ded489d4015

Upgrade to geese 3

DDouglasDwyer committed a year ago
Unverified
837a1330130e68e0c5b1745992c004f5fded0038

Generalize FutureBuilder cancellation

DDouglasDwyer committed 2 years ago
Unverified
55e06b49afe14f9d03ae32230d37af054a2c7c9d

Upgrade Geese and clippy

DDouglasDwyer committed 2 years ago
Unverified
ddf38d3def6f0b3aef9b5f52e41779b1aa63a734

Update README.md

DDouglasDwyer committed 2 years ago
Unverified
7f222788018d5887144452e9b1880f06c6a903e1

Update lib.rs

DDouglasDwyer committed 2 years ago
Unverified
379196057fc680c0d2117fc8300ccc364d8d3681

Get ready for publish

DDouglasDwyer committed 2 years ago

README

The README file for this repository.

geese_executor

Crates.io Docs.rs

Geese executor is a runtime for futures, integrated into the Geese event system. It provides the ability to perform asynchronous work and then send the results back via events. Each time the geese_executor::notify::Poll event is raised, each future will be polled a single time, and any events raised by futures will be broadcast to all other systems.

A simple example of executor usage is provided below.

use geese::*;
use geese_executor::*;

struct A {
    cancellation: CancellationToken,
    result: Option<i32>
}

impl A {
    async fn do_background_work() -> i32 {
        // Do some awaiting
        42
    }

    fn handle_result(&mut self, future_result: &i32) {
        self.result = Some(*future_result);
    }
}

impl GeeseSystem for A {
    const DEPENDENCIES: Dependencies = dependencies()
        .with::<GeeseExecutor>();

    const EVENT_HANDLERS: EventHandlers<Self> = event_handlers()
        .with(Self::handle_result);

    fn new(ctx: GeeseContextHandle<Self>) -> Self {
        let cancellation = CancellationToken::default();
        let result = None;

        ctx.get::<GeeseExecutor>().spawn_event(Self::do_background_work())
            .with_cancellation(&cancellation);

        Self { cancellation, result }
    }
}

let mut ctx = GeeseContext::default();
ctx.flush(EventQueue::default()
    .with(geese::notify::add_system::<A>())
    .with(geese_executor::notify::Poll)
);
assert_eq!(Some(42), ctx.get::<A>().result);