()
| 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 |
nothing calls this directly
no test coverage detected