aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md1
-rw-r--r--CONTRIBUTING.md2
-rw-r--r--book/en/src/by-example/resources.md12
-rw-r--r--book/en/src/migration/migration_v5.md19
4 files changed, 27 insertions, 7 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0d30960..702d489 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -19,6 +19,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Fixed
+- Fix dated migration docs for spawn
- Force mdBook to return error codes
- Readded missing ramfunc output to book
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index daaba78..9c6a861 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -4,7 +4,7 @@
New features should go through the [RFC process][rfcs] before creating a Pull Request to this repository.
-[rfcs](https://github.com/rtic-rs/rfcs)
+[rfcs]: https://github.com/rtic-rs/rfcs
## Bugs
diff --git a/book/en/src/by-example/resources.md b/book/en/src/by-example/resources.md
index 6426913..9d51d6c 100644
--- a/book/en/src/by-example/resources.md
+++ b/book/en/src/by-example/resources.md
@@ -30,6 +30,11 @@ task.
Thus, a task `#[local]` resource can only be accessed by one singular task.
Attempting to assign the same `#[local]` resource to more than one task is a compile-time error.
+Types of `#[local]` resources must implement [`Send`] trait as they are being sent from `init`
+to target task and thus crossing the thread boundary.
+
+[`Send`]: https://doc.rust-lang.org/stable/core/marker/trait.Send.html
+
The example application shown below contains two tasks where each task has access to its own
`#[local]` resource, plus that the `idle` task has its own `#[local]` as well.
@@ -51,6 +56,11 @@ A special use-case of local resources are the ones specified directly in the res
initialized in `#[init]`.
Moreover, local resources in `#[init]` and `#[idle]` have `'static` lifetimes, this is safe since both are not re-entrant.
+Types of `#[task(local = [..])]` resources have to be neither [`Send`] nor [`Sync`] as they
+are not crossing any thread boundary.
+
+[`Sync`]: https://doc.rust-lang.org/stable/core/marker/trait.Sync.html
+
In the example below the different uses and lifetimes are shown:
``` rust
@@ -95,6 +105,8 @@ $ cargo run --target thumbv7m-none-eabi --example lock
{{#include ../../../../ci/expected/lock.run}}
```
+Types of `#[shared]` resources have to be both [`Send`] and [`Sync`].
+
## Multi-lock
As an extension to `lock`, and to reduce rightward drift, locks can be taken as tuples. The
diff --git a/book/en/src/migration/migration_v5.md b/book/en/src/migration/migration_v5.md
index e19fb62..731931f 100644
--- a/book/en/src/migration/migration_v5.md
+++ b/book/en/src/migration/migration_v5.md
@@ -316,11 +316,10 @@ mod app {
}
```
-## Spawn/schedule from anywhere
-
-With the new "spawn/schedule from anywhere", old code such as:
-
+## Spawn from anywhere
+With the new spawn/spawn_after/spawn_at interface,
+old code requiring the context `cx` for spawning such as:
``` rust
#[task(spawn = [bar])]
@@ -344,12 +343,20 @@ fn foo(_c: foo::Context) {
#[task]
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.
---