Crate screeps_async

Source
Expand description

A tick-aware async runtime for Screeps

§Getting Started

Add screeps-async to your Cargo.toml

[dependencies]
screeps-async = "0.3.1"

§The #[screeps_async::main] macro

#[screeps_async::main]
pub fn game_loop() {
    // Tick logic that spawns some tasks
    screeps_async::spawn(async {
        println!("Hello!");
    });
}

This expands to roughly the following:

pub fn game_loop() {
    // Tick logic that spawns some tasks
    screeps_async::spawn(async {
        println!("Hello!");
    });

    screeps_async::run().unwrap();
}

Re-exports§

pub use macros::*;

Modules§

error
Errors emitted by screeps-async
job
See JobHandle
macros
Macros to make common workflows easier
runtime
The Screeps Async runtime
sync
Synchronization primitives for async contexts
time
Utilities for tracking time

Macros§

each_tick
Run a block of code each tick, resolving the specified list of dependencies by calling .resolve each tick and exiting if any dependency can’t be resolved.

Constants§

CURRENT
The current runtime

Functions§

block_on
The main entrypoint for the async runtime. Runs a future to completion.
initialize
Configures the runtime with default settings. Must be called only once
run
Run the task executor for one tick
spawn
Spawn a new async task
with_runtime
Acquire a reference to the ScreepsRuntime.