Struct neon::handle::Root [−][src]
pub struct Root<T> { /* fields omitted */ }
Expand description
A thread-safe handle that holds a reference to a JavaScript object and prevents it from being garbage collected.
A Root<T>
may be sent across threads, but the referenced object may
only be accessed on the JavaScript thread that created it.
Implementations
impl<T: Object> Root<T>
[src]
impl<T: Object> Root<T>
[src]pub fn new<'a, C: Context<'a>>(cx: &mut C, value: &T) -> Self
[src]
pub fn new<'a, C: Context<'a>>(cx: &mut C, value: &T) -> Self
[src]Create a reference to a JavaScript object. The object will not be
garbage collected until the Root
is dropped. A Root<T>
may only
be dropped on the JavaScript thread that created it.
The caller should ensure Root::into_inner
or Root::drop
is called
to properly dispose of the Root<T>
. If the value is dropped without
calling one of these methods:
- N-API < 6, Neon will
panic
to notify of the leak - N-API >= 6, Neon will drop from a global queue at a runtime cost
pub fn clone<'a, C: Context<'a>>(&self, cx: &mut C) -> Self
[src]
pub fn clone<'a, C: Context<'a>>(&self, cx: &mut C) -> Self
[src]Clone a reference to the contained JavaScript object. This method can be considered identical to the following:
let inner = root.into_inner(&mut cx); let cloned = inner.root(&mut cx); let root = inner.root(&mut cx);
pub fn drop<'a, C: Context<'a>>(self, cx: &mut C)
[src]
pub fn drop<'a, C: Context<'a>>(self, cx: &mut C)
[src]Safely drop a Root<T>
without returning the referenced JavaScript
object.
pub fn into_inner<'a, C: Context<'a>>(self, cx: &mut C) -> Handle<'a, T>
[src]
pub fn into_inner<'a, C: Context<'a>>(self, cx: &mut C) -> Handle<'a, T>
[src]Return the referenced JavaScript object and allow it to be garbage collected
Trait Implementations
impl<T> Send for Root<T>
[src]
impl<T> Sync for Root<T>
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for Root<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Unpin for Root<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Root<T> where
T: UnwindSafe,
T: UnwindSafe,