-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #444 from stlankes/tokio
add tokio example
- Loading branch information
Showing
3 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
[package] | ||
name = "tokio-minimal" | ||
authors = ["Stefan Lankes <[email protected]>"] | ||
version = "0.1.0" | ||
edition = "2021" | ||
publish = false | ||
|
||
[dependencies] | ||
tokio = { version = "1.19", default-features = false, features = ["rt", "rt-multi-thread", "macros"] } | ||
|
||
[target.'cfg(target_os = "hermit")'.dependencies.hermit-sys] | ||
path = "../../hermit-sys" | ||
default-features = false | ||
|
||
[features] | ||
default = ["pci", "pci-ids", "acpi", "dhcpv4", "tcp"] | ||
vga = ["hermit-sys/vga"] | ||
dhcpv4 = ["hermit-sys/dhcpv4"] | ||
pci = ["hermit-sys/pci"] | ||
pci-ids = ["hermit-sys/pci-ids"] | ||
acpi = ["hermit-sys/acpi"] | ||
fsgsbase = ["hermit-sys/fsgsbase"] | ||
smp = ["hermit-sys/smp"] | ||
tcp = ["hermit-sys/tcp"] | ||
instrument = ["hermit-sys/instrument"] | ||
trace = ["hermit-sys/trace"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// A minimal tokio example. Network support is currently not supported. | ||
|
||
#[cfg(target_os = "hermit")] | ||
use hermit_sys as _; | ||
|
||
async fn say_world() { | ||
println!("world"); | ||
} | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
// Calling `say_world()` does not execute the body of `say_world()`. | ||
let op = say_world(); | ||
|
||
// This println! comes first | ||
println!("hello"); | ||
|
||
// Calling `.await` on `op` starts executing `say_world`. | ||
op.await; | ||
} |