Skip to content

Commit 9def58c

Browse files
committed
added requirements, clarified run_time call
1 parent 9c70810 commit 9def58c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/recipes/tokio_runtime.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
This recipe is based off of the test written for `gdnative-async`, which uses the `futures` crate in the executor. For cases where you may need a `tokio` runtime, it is possible to execute spawned tokio tasks in much the same way, with some alterations.
44

5+
## Requirements
6+
This recipe requires the following entries in your Cargo.toml file
7+
8+
```toml
9+
tokio = { version = "1.10", features = ["rt"] }
10+
gdnative = { git = "https://github.com/godot-rust/godot-rust.git", features = ["async"]}
11+
```
12+
513
## Defining the Executor
614
The executor itself can be defined the same way.
715

@@ -61,7 +69,7 @@ impl AsyncExecutorDriver {
6169
}
6270
```
6371

64-
In the `_process` call of our `AsyncExecutorDriver`, we can block on `run_until` on the `LocalSet`, which will run or wake any of its local tasks.
72+
In the `_process` call of our `AsyncExecutorDriver`, we can block on `run_until` on the `LocalSet`. `run_until` will automatically resume all tasks on the local set until the provided future is completed. Since we don't want to block the frame, and we'd be checking every frame anyway, we just provide an empty task and await it.
6573

6674
```rust
6775
#[methods]

0 commit comments

Comments
 (0)