Struct netsblox_vm::gc::RefLock
source · pub struct RefLock<T>where
T: ?Sized,{ /* private fields */ }
Expand description
Implementations§
source§impl<T> RefLock<T>
impl<T> RefLock<T>
sourcepub fn new(t: T) -> RefLock<T>
pub fn new(t: T) -> RefLock<T>
Examples found in repository?
examples/basic.rs (line 90)
79 80 81 82 83 84 85 86 87 88 89 90 91 92
fn get_running_project(xml: &str, system: Rc<StdSystem<C>>) -> EnvArena {
EnvArena::new(|mc| {
let parser = ast::Parser::default();
let ast = parser.parse(xml).unwrap();
assert_eq!(ast.roles.len(), 1); // this should be handled more elegantly in practice - for the sake of this example, we only allow one role
let (bytecode, init_info, locs, _) = ByteCode::compile(&ast.roles[0]).unwrap();
let mut proj = Project::from_init(mc, &init_info, Rc::new(bytecode), Settings::default(), system);
proj.input(mc, Input::Start); // this is equivalent to clicking the green flag button
Env { proj: Gc::new(mc, RefLock::new(proj)), locs }
})
}
pub fn into_inner(self) -> T
pub fn take(&self) -> Twhere
T: Default,
source§impl<T> RefLock<T>where
T: ?Sized,
impl<T> RefLock<T>where
T: ?Sized,
pub fn as_ptr(&self) -> *mut T
pub fn borrow<'a>(&'a self) -> Ref<'a, T>
pub fn try_borrow<'a>(&'a self) -> Result<Ref<'a, T>, BorrowError>
sourcepub unsafe fn as_ref_cell(&self) -> &RefCell<T>
pub unsafe fn as_ref_cell(&self) -> &RefCell<T>
Access the wrapped RefCell
.
Safety
In order to maintain the invariants of the garbage collector, no new Gc
pointers may be adopted by this type as a result of the interior mutability
afforded by directly accessing the inner RefCell
, unless the write barrier for the containing Gc
pointer is invoked manuall
before collection is triggered.
pub fn get_mut(&mut self) -> &mut T
Trait Implementations§
source§impl<'gc, T> Collect for RefLock<T>where
T: Collect + 'gc,
impl<'gc, T> Collect for RefLock<T>where
T: Collect + 'gc,
source§fn needs_trace() -> bool
fn needs_trace() -> bool
As an optimization, if this type can never hold a
Gc
pointer and trace
is unnecessary
to call, you may implement this method and return false. The default implementation returns
true, signaling that Collect::trace
must be called.source§fn trace(&self, cc: &Collection)
fn trace(&self, cc: &Collection)
Must call
Collect::trace
on all held Gc
pointers. If this type holds inner types that
implement Collect
, a valid implementation would simply call Collect::trace
on all the
held values to ensure this.source§impl<T> PartialEq for RefLock<T>
impl<T> PartialEq for RefLock<T>
source§impl<T> PartialOrd for RefLock<T>where
T: PartialOrd + ?Sized,
impl<T> PartialOrd for RefLock<T>where
T: PartialOrd + ?Sized,
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl<T> Eq for RefLock<T>
impl<T> StructuralEq for RefLock<T>where
T: ?Sized,
impl<T> StructuralPartialEq for RefLock<T>where
T: ?Sized,
Auto Trait Implementations§
impl<T> !RefUnwindSafe for RefLock<T>
impl<T: ?Sized> Send for RefLock<T>where
T: Send,
impl<T> !Sync for RefLock<T>
impl<T: ?Sized> Unpin for RefLock<T>where
T: Unpin,
impl<T: ?Sized> UnwindSafe for RefLock<T>where
T: UnwindSafe,
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
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.