Skip to content
This repository was archived by the owner on Oct 30, 2019. It is now read-only.
This repository was archived by the owner on Oct 30, 2019. It is now read-only.

some unexpected panic #29

@huangjj27

Description

@huangjj27

hello world example is modified as follow:

# Cargo.toml
[package]
name = "async_runtime"
version = "0.1.0"
authors = ["huangjj27 <[email protected]>"]
edition = "2018"

[dependencies]
runtime = "0.3.0-alpha.3"
futures-preview = "0.3.0-alpha.15"
// main.rs
#![feature(async_await, await_macro)]

async fn say_hi(num: usize) {
    println!("Hello, async - {}!", num);
}

#[runtime::main]
async fn main() {
    for i in 1..=100 {
        runtime::spawn(async move {
            let i = i;
            say_hi(i).await;

            Ok::<(), std::io::Error>(())
        });
    }
}

then, run:

PS E:\learning-rust\async_runtime> cargo +nightly run
   Compiling async_runtime v0.1.0 (E:\learning-rust\async_runtime)
    Finished dev [unoptimized + debuginfo] target(s) in 3.16s
     Running `target\debug\async_runtime.exe`
Hello, async - 2!
Hello, async - 3!
Hello, async - 4!
Hello, async - 5!
Hello, async - 6!
Hello, async - 7!
Hello, async - 8!
Hello, async - 9!
Hello, async - 10!
Hello, async - 11!
Hello, async - 16!
Hello, async - 13!
Hello, async - 14!
Hello, async - 15!

and run again:

PS E:\learning-rust\async_runtime> cargo +nightly run
    Finished dev [unoptimized + debuginfo] target(s) in 0.27s
     Running `target\debug\async_runtime.exe`
Hello, async - 1!
Hello, async - 3!
thread 'thread 'thread 'Hello, async - 2!
thread '<unnamed>thread 'thread '<unnamed>thread '<unnamed><unnamed>' panicked at '<unnamed><unnamed>' panicked at '

Expected Behaviour

It should print 100 times with no specific order

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions