forked from tokio-rs/tokio
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
macros: spawn main task and block on it
It is well-known that `#[tokio::main]` and `#[tokio::test]` require only `Future` but not `Send`. But occasionally, most likely in tests, people want to make sure those entry futures themselves are `Send`. Currently, they have to do the spawning manually for each entries. This is tedious. Having `spawn = true` could easily solve this case.
- Loading branch information
Showing
4 changed files
with
95 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
use std::rc::Rc; | ||
|
||
use tests_build::tokio; | ||
|
||
async fn send_f() {} | ||
|
||
#[tokio::test(spawn = true)] | ||
async fn no_send_test() { | ||
let _value = Rc::new(0); | ||
send_f().await; | ||
} | ||
|
||
#[tokio::main(spawn = true)] | ||
async fn no_send_main() { | ||
let _value = Rc::new(0); | ||
send_f().await; | ||
} |
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
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