diff options
| author | Jorge Aparicio <jorge@japaric.io> | 2019-04-21 18:20:15 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-04-21 18:20:15 +0200 |
| commit | b5a756bd7d394226e505f0cb4f91a5de01d9b950 (patch) | |
| tree | 30b0955299a85109869eefa13284f4ee3141eb45 /book/en/src/by-example | |
| parent | 77def324548e204d3a36a4e89eb528904c381158 (diff) | |
| parent | 473a0e7bb58c1ec4b10dea505056ad76f9023871 (diff) | |
Merge pull request #169 from japaric/late-must-be-send
book: note that late resources must be Send
Diffstat (limited to 'book/en/src/by-example')
| -rw-r--r-- | book/en/src/by-example/types-send-sync.md | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/book/en/src/by-example/types-send-sync.md b/book/en/src/by-example/types-send-sync.md index da53cf9..632946b 100644 --- a/book/en/src/by-example/types-send-sync.md +++ b/book/en/src/by-example/types-send-sync.md @@ -39,6 +39,19 @@ The example below shows where a type that doesn't implement `Send` can be used. {{#include ../../../../examples/not-send.rs}} ``` +It's important to note that late initialization of resources is effectively a +send operation where the initial value is sent from `idle`, which has the lowest +priority of `0`, to a task with will run with a priority greater than or equal +to `1`. Thus all late resources need to implement the `Send` trait. + +Sharing a resource with `init` can be used to implement late initialization, see +example below. For that reason, resources shared with `init` must also implement +the `Send` trait. + +``` rust +{{#include ../../../../examples/shared-with-init.rs}} +``` + ## `Sync` Similarly, [`Sync`] is a marker trait for "types for which it is safe to share |
