607: Docs: Fix dated migration docs for spawn r=korken89 a=AfoHT



Co-authored-by: Henrik Tjäder <henrik@grepit.se>
This commit is contained in:
bors[bot] 2022-02-10 09:26:59 +00:00 committed by GitHub
commit a98058c2a0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 6 deletions

View file

@ -19,6 +19,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Fixed ### Fixed
- Fix dated migration docs for spawn
- Force mdBook to return error codes - Force mdBook to return error codes
- Readded missing ramfunc output to book - Readded missing ramfunc output to book

View file

@ -316,11 +316,10 @@ mod app {
} }
``` ```
## Spawn/schedule from anywhere ## Spawn from anywhere
With the new "spawn/schedule from anywhere", old code such as:
With the new spawn/spawn_after/spawn_at interface,
old code requiring the context `cx` for spawning such as:
``` rust ``` rust
#[task(spawn = [bar])] #[task(spawn = [bar])]
@ -344,12 +343,20 @@ fn foo(_c: foo::Context) {
#[task] #[task]
fn bar(_c: bar::Context) { fn bar(_c: bar::Context) {
foo::schedule(/* ... */).unwrap(); // Takes a Duration, relative to “now”
let spawn_handle = foo::spawn_after(/* ... */);
}
#[task]
fn bar(_c: bar::Context) {
// Takes an Instant
let spawn_handle = foo::spawn_at(/* ... */);
} }
``` ```
Note that the attributes `spawn` and `schedule` are no longer needed. Thus the requirement of having access to the context is dropped.
Note that the attributes `spawn`/`schedule` in the task definition are no longer needed.
--- ---