Skip to content

Commit fa0ade5

Browse files
Mention scoped threads
1 parent 11b2b01 commit fa0ade5

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/threading/index.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,17 @@ A few things to note:
119119
`data` must be copied or cloned (depending on what the type of the value
120120
supports).
121121

122+
Since Rust 1.63.0, it is possible to use [scoped threads] to use non-static data
123+
(including references to not-`move`d values) in threads. The trade-off is that
124+
since the data must remain alive until the thread's end, it is forcibly joined
125+
by the end of the scope.
126+
122127
- Rust thread can return values, like tasks in C#, which becomes the return
123128
value of the `join` method.
124129

125130
- It is possible to also pass data to the C# thread via a closure, like the
126131
Rust example, but the C# version does not need to worry about ownership
127132
since the memory behind the data will be reclaimed by the GC once no one is
128133
referencing it anymore.
134+
135+
[scoped threads]: https://doc.rust-lang.org/stable/std/thread/fn.scope.html

0 commit comments

Comments
 (0)