@@ -24,6 +24,17 @@ use unwind;
24
24
/// by a mutex, or some such thing). If you want to compute a result,
25
25
/// consider `spawn_future()`.
26
26
///
27
+ /// There is no guaranteed order of execution for spawns, given that
28
+ /// other threads may steal tasks at any time. However, they are
29
+ /// generally prioritized in a LIFO order on the thread from which
30
+ /// they were spawned. Other threads always steal from the other end of
31
+ /// the deque, like FIFO order. The idea is that "recent" tasks are
32
+ /// most likely to be fresh in the local CPU's cache, while other
33
+ /// threads can steal older "stale" tasks. For an alternate approach,
34
+ /// consider [`spawn_fifo()`] instead.
35
+ ///
36
+ /// [`spawn_fifo()`]: fn.spawn_fifo.html
37
+ ///
27
38
/// # Panic handling
28
39
///
29
40
/// If this closure should panic, the resulting panic will be
@@ -98,7 +109,32 @@ where
98
109
. as_job_ref ( )
99
110
}
100
111
101
- /// TODO: like `spawn`, but FIFO
112
+ /// Fires off a task into the Rayon threadpool in the "static" or
113
+ /// "global" scope. Just like a standard thread, this task is not
114
+ /// tied to the current stack frame, and hence it cannot hold any
115
+ /// references other than those with `'static` lifetime. If you want
116
+ /// to spawn a task that references stack data, use [the `scope_fifo()`
117
+ /// function](fn.scope_fifo.html) to create a scope.
118
+ ///
119
+ /// The behavior is essentially the same as [the `spawn`
120
+ /// function](fn.spawn.html), except that calls from the same thread
121
+ /// will be prioritized in FIFO order. This is similar to the now-
122
+ /// deprecated [`breadth_first`] option, except the effect is isolated
123
+ /// to relative `spawn_fifo` calls, not all threadpool tasks.
124
+ ///
125
+ /// For more details on this design, see Rayon [RFC #1].
126
+ ///
127
+ /// [`breadth_first`]: struct.ThreadPoolBuilder.html#method.breadth_first
128
+ /// [RFC #1]: https://github.com/rayon-rs/rfcs/blob/master/accepted/rfc0001-scope-scheduling.md
129
+ ///
130
+ /// # Panic handling
131
+ ///
132
+ /// If this closure should panic, the resulting panic will be
133
+ /// propagated to the panic handler registered in the `ThreadPoolBuilder`,
134
+ /// if any. See [`ThreadPoolBuilder::panic_handler()`][ph] for more
135
+ /// details.
136
+ ///
137
+ /// [ph]: struct.ThreadPoolBuilder.html#method.panic_handler
102
138
pub fn spawn_fifo < F > ( func : F )
103
139
where
104
140
F : FnOnce ( ) + Send + ' static ,
0 commit comments