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

Function scope_borrow

src/scope.rs:1048–1061  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1046
1047 use super::Scope;
1048
1049 /// A reference-counted pointer to a scope. Used to capture a scope pointer
1050 /// in jobs without faking a lifetime. Holding a `ScopePtr` keeps the
1051 /// reference scope from being deallocated.
1052 pub struct ScopePtr<'scope, 'env>(*const Scope<'scope, 'env>);
1053
1054 // SAFETY: Sending the `*const Scope` is sound because the pointee outlives
1055 // every `ScopePtr` (the refcount is held until drop), all cross-thread
1056 // mutation of the `Scope` goes through atomics, and its remaining fields are
1057 // written only during construction, so shared reads cannot race.
1058 unsafe impl Send for ScopePtr<'_, '_> {}
1059
1060 impl<'scope, 'env> ScopePtr<'scope, 'env> {
1061 /// Creates a new reference-counted scope pointer which can be sent to other
1062 /// threads.
1063 pub fn new(scope: &Scope<'scope, 'env>) -> ScopePtr<'scope, 'env> {
1064 // Add a reference to ensure the scope will stay alive at least

Callers

nothing calls this directly

Calls 4

resize_to_availableMethod · 0.80
scopeMethod · 0.80
depopulateMethod · 0.80
spawnMethod · 0.45

Tested by

no test coverage detected