#async-pool #signal #cbsk #run #tool #callback #sockets

cbsk_run

cbsk_run is async pool tool

17 releases (11 stable)

2.0.6 Nov 15, 2024
2.0.0 Aug 21, 2024
1.3.11 Aug 19, 2024
1.3.10 Jul 26, 2024
0.1.5 Dec 20, 2023

#644 in Asynchronous

Download history 298/week @ 2024-08-17 21/week @ 2024-08-24 134/week @ 2024-08-31 15/week @ 2024-09-07 1/week @ 2024-09-14 35/week @ 2024-09-21 17/week @ 2024-09-28 1/week @ 2024-10-05 4/week @ 2024-10-12 32/week @ 2024-11-02 83/week @ 2024-11-09 42/week @ 2024-11-16 3/week @ 2024-11-23

160 downloads per month

MIT/Apache

27KB
397 lines

cbsk_run is async pool tool
the main functions include async pool and signal::run

support the minimum version of Rust

1.80.0

signal::run example

Cargo.toml file :

cbsk_base = { version = "2.0.6" }
cbsk_run = { version = "2.0.6" }

main.rs file :

use std::time::Duration;
use cbsk_base::{anyhow, tokio};
use cbsk_base::tokio::task::JoinHandle;

#[tokio::main]
async fn main() {
    cbsk_run::run::signal::run(runnable()).await
}

fn runnable() -> anyhow::Result<Vec<JoinHandle<()>>> {
    Ok(vec![hello_world(), say_hi()])
}

fn hello_world() -> JoinHandle<()> {
    tokio::spawn(async {
        loop {
            println!("hello world");
            tokio::time::sleep(Duration::from_secs(1)).await;
        }
    })
}

fn say_hi() -> JoinHandle<()> {
    tokio::spawn(async {
        loop {
            println!("hi!");
            tokio::time::sleep(Duration::from_secs(2)).await;
        }
    })
}

running results :

E:\work\github\rust\cbsk_test>cargo run
Compiling cbsk_run v0.1.0 (E:\work\github\rust\cbsk\libs\cbsk_run)
Compiling cbsk_test v0.1.0 (E:\work\github\rust\cbsk_test)
Finished dev [unoptimized + debuginfo] target(s) in 4.21s
Running E:\work\cache\rust\github\target\debug\cbsk_test.exe
hello world
hi!
hello world
hello world
hi!
hello world
hello world
hi!
hello world
hello world
hi!
hello world
hello world
hi!
hello world
hello world
hi!
hello world
hi!
hello world
hello world
hello world
hi!
hello world

E:\work\github\rust\cbsk_test>

Dependencies

~2.5–8.5MB
~62K SLoC