pub struct SharedCell { /* private fields */ }Expand description
Implementations§
Sourcepub fn new(value: Transfer) -> Arc<SharedCell>
pub fn new(value: Transfer) -> Arc<SharedCell>
Wraps an already converted value.
Sourcepub fn wrap(value: &Value, span: Span) -> Result<Arc<SharedCell>, RuntimeError>
pub fn wrap(value: &Value, span: Span) -> Result<Arc<SharedCell>, RuntimeError>
Shared(value): wraps value, or reports why it may not be wrapped.
The payload must be task-safe for the same reason a spawned closure’s
captures must be. A Shared<Vector<T>> would let a vector be reached
from two tasks, which is exactly what the sentence naming Shared
forbids.
Sourcepub fn lock<R>(
&self,
span: Span,
body: impl FnOnce(Value) -> Result<(R, Value), RuntimeError>,
) -> Result<R, RuntimeError>
pub fn lock<R>( &self, span: Span, body: impl FnOnce(Value) -> Result<(R, Value), RuntimeError>, ) -> Result<R, RuntimeError>
Runs body with the wrapped value, holding the lock for the whole
call, and stores back whatever body leaves in it.
body receives the value and returns its own result together with the
value to store — which is the same value when the closure took it as a
var alias and mutated it in place. A body that raises an error
stores nothing, so a half-finished modification is never left behind
for another task to find.
Trait Implementations§
Auto Trait Implementations§
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more