Skip to content

Commit

Permalink
Use multithreaded tokio runtime by default
Browse files Browse the repository at this point in the history
  • Loading branch information
temeddix committed Sep 9, 2024
1 parent 149098b commit 8d04ff9
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion documentation/docs/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ rinf message
Define an async Rust function that runs forever, sending numbers to Dart every second.

```toml title="native/hub/Cargo.toml"
tokio = { version = "1", features = ["sync", "rt", "time"] }
tokio = { version = "1", features = ["sync", "time"] }
```

```rust title="native/hub/src/tutorial_functions.rs"
Expand Down
11 changes: 8 additions & 3 deletions flutter_ffi_plugin/example/native/hub/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,17 @@ crate-type = ["lib", "cdylib", "staticlib"]
[dependencies]
rinf = "6.15.0"
prost = "0.13.0"
tokio = { version = "1", features = ["rt", "sync", "time", "macros"] }
tokio_with_wasm = { version = "0.7.1", features = [
"rt",
tokio = { version = "1", features = [
"rt-multi-thread",
"macros",
"sync",
"time",
] }
tokio_with_wasm = { version = "0.7.1", features = [
"rt-multi-thread",
"macros",
"sync",
"time",
] }
wasm-bindgen = "0.2.93"
sample_crate = { path = "../sample_crate" }
2 changes: 1 addition & 1 deletion flutter_ffi_plugin/example/native/hub/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ rinf::write_interface!();
// such as `tokio::fs::File::open`.
// If you really need to use blocking code,
// use `tokio::task::spawn_blocking`.
#[tokio::main(flavor = "current_thread")]
#[tokio::main]
async fn main() -> Result<()> {
// Spawn the concurrent tasks.
tokio::spawn(sample_functions::tell_numbers());
Expand Down
7 changes: 5 additions & 2 deletions flutter_ffi_plugin/template/native/hub/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ crate-type = ["lib", "cdylib", "staticlib"]
[dependencies]
rinf = "6.15.0"
prost = "0.12.6"
tokio = { version = "1", features = ["rt", "macros"] }
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }

# Uncomment below to target the web.
# tokio_with_wasm = { version = "0.6.0", features = ["rt", "macros"] }
# tokio_with_wasm = { version = "0.7.1", features = [
# "rt-multi-thread",
# "macros",
# ] }
# wasm-bindgen = "0.2.93"
2 changes: 1 addition & 1 deletion flutter_ffi_plugin/template/native/hub/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ rinf::write_interface!();
// such as `tokio::fs::File::open`.
// If you really need to use blocking code,
// use `tokio::task::spawn_blocking`.
#[tokio::main(flavor = "current_thread")]
#[tokio::main]
async fn main() -> Result<()> {
// Spawn the concurrent tasks.
tokio::spawn(communicate());
Expand Down

0 comments on commit 8d04ff9

Please sign in to comment.