MCPcopy Create free account
hub / github.com/NthTensor/Forte / spawn

Method spawn

src/scope.rs:161–174  ·  view source on GitHub ↗

Runs a closure or future sometime before the scope completes. This is like [`Worker::spawn`], allows the work to borrow local data. Vald inputs to this method are: A `for<'worker> FnOnce(&'worker Worker)` closure, with no return type. A `Future ` future, with no return type.

(&'scope self, work: S)

Source from the content-addressed store, hash-verified

159 ///
160 /// * A `Future<Output = ()>` future, with no return type.
161 pub fn spawn<M, S>(&'scope self, work: S)
162 where
163 S: SpawnScoped<'scope, M> + Send,
164 {
165 let thread_pool = self.thread_pool;
166 let scheduler = |job_ref, worker: Option<&Worker>| match worker {
167 Some(worker) => worker.fifo_queue.push_new(job_ref),
168 None => thread_pool.push_shared_job(job_ref),
169 };
170 // SAFETY: `spawn_scoped` requires that `!Send` work only be scheduled
171 // to run on the current thread. Here `S: Send`, so that obligation is
172 // vacuous.
173 unsafe { work.spawn_scoped(self, scheduler) };
174 }
175
176 /// Like [`spawn`](Self::spawn), but routes the work to a specific pool
177 /// member so it runs on that member's thread.

Callers 15

visitFunction · 0.45
rayonFunction · 0.45
scope_twoFunction · 0.45
scope_borrowFunction · 0.45
scope_borrow_twiceFunction · 0.45
scope_futureFunction · 0.45
scope_pending_futureFunction · 0.45
scope_sleeping_futureFunction · 0.45
scope_concurrencyFunction · 0.45
scope_nestingFunction · 0.45
scope_nesting_new_workerFunction · 0.45
scope_divide_and_conquerFunction · 0.45

Calls 3

push_newMethod · 0.80
push_shared_jobMethod · 0.80
spawn_scopedMethod · 0.80

Tested by 11

scope_twoFunction · 0.36
scope_borrowFunction · 0.36
scope_borrow_twiceFunction · 0.36
scope_futureFunction · 0.36
scope_pending_futureFunction · 0.36
scope_sleeping_futureFunction · 0.36
scope_concurrencyFunction · 0.36
scope_nestingFunction · 0.36
scope_nesting_new_workerFunction · 0.36
scope_divide_and_conquerFunction · 0.36
scope_staticFunction · 0.36