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

Method store_panic

src/scope.rs:336–376  ·  view source on GitHub ↗
(&self, err: Box<dyn Any + Send + 'static>)

Source from the content-addressed store, hash-verified

334 /// counter was incremented by one. This could be through a call to
335 /// `add_reference`, a direct `fetch_add` on the underlying counter, or the
336 /// implicit initial increment the scope starts with.
337 unsafe fn remove_reference(&self) {
338 // This is `Release` so that this job's accesses to the scope are
339 // ordered before the decrement.
340 //
341 // The std-lib's `Arc` has the same basic pattern.
342 let counter = self.count.fetch_sub(1, Ordering::Release);
343 if counter == 1 {
344 // This is the final decrement.
345 //
346 // The `Acquire` fence synchronizes with the release sequence formed
347 // by every other job's `Release` decrement of `count`, so all of
348 // their accesses to the scope happen-before this point. Combined
349 // with the `Release`/`Acquire` handshake in
350 // `Latch::set`/`Latch::check`, this orders every job's use of the
351 // scope before the owner returns from `complete` and frees it.
352 // Without it, remote jobs' atomic ops on `count` (and their reads
353 // and writes of `panic`) would race the owner's deallocation.
354 fence(Ordering::Acquire);
355 // Alerts the owning thread that the scope has completed.
356 //
357 // This should never panic, because the counter can only go to zero
358 // once, when the scope has been dropped and all work has been
359 // completed.
360 //
361 // SAFETY: We meet Variant 2 of the `Latch::set` safety contract:
362 //
363 // * The count reaches zero exactly once, so this branch runs
364 // exactly once, and this is the only place the latch is set. So
365 // no other call to `set` can race with this one, and `set` cannot
366 // have already been called.
367 //
368 // * This latch will not be dropped until `complete` returns, and
369 // `complete` will not return until it observes the signal we are
370 // about to send.
371 unsafe { Latch::set(&self.completed, false) };
372 }
373 }
374
375 /// Stores a panic so that it can be propagated when the scope is complete.
376 /// If called multiple times, only the first panic is stored, and the
377 /// remainder are dropped.
378 ///
379 /// This function never unwinds, but may abort in circumstances.

Callers 4

with_scopeFunction · 0.80
spawn_broadcastMethod · 0.80
spawn_scopedMethod · 0.80
pollMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected