Struct jlrs::CCall [−][src]
pub struct CCall { /* fields omitted */ }
Expand description
When you call Rust from Julia through ccall
, Julia has already been initialized and trying to
initialize it again would cause a crash. In order to still be able to call Julia from Rust
and to borrow arrays (if you pass them as Array
rather than Ptr{Array}
), you’ll need to
create a frame first. You can use this struct to do so. It must never be used outside
functions called through ccall
, and only once for each ccall
ed function.
If you only need to use a frame to borrow array data, you can use CCall::null_scope
.
Unlike Julia
, CCall
postpones the allocation of the stack that is used for managing the
GC until a GcFrame
is created. In the case of a null scope, this stack isn’t allocated at
all.
Implementations
Create a new CCall
. This function must never be called outside a function called through
ccall
from Julia and must only be called once during that call. The stack is not
allocated until a GcFrame
is created.
Wake the task associated with handle
. The handle must be the handle
field of a
Base.AsyncCondition
in Julia. This can be used to call a long-running Rust function from
Julia with ccall in another thread and wait for it to complete in Julia without blocking,
there’s an example available in the repository: ccall_with_threads.
pub fn scope<T, F>(&mut self, func: F) -> JlrsResult<T> where
for<'base> F: FnOnce(Global<'base>, &mut GcFrame<'base, Sync>) -> JlrsResult<T>,
pub fn scope<T, F>(&mut self, func: F) -> JlrsResult<T> where
for<'base> F: FnOnce(Global<'base>, &mut GcFrame<'base, Sync>) -> JlrsResult<T>,
Creates a GcFrame
, calls the given closure, and returns its result.
pub fn scope_with_slots<T, F>(&mut self, slots: usize, func: F) -> JlrsResult<T> where
for<'base> F: FnOnce(Global<'base>, &mut GcFrame<'base, Sync>) -> JlrsResult<T>,
pub fn scope_with_slots<T, F>(&mut self, slots: usize, func: F) -> JlrsResult<T> where
for<'base> F: FnOnce(Global<'base>, &mut GcFrame<'base, Sync>) -> JlrsResult<T>,
Creates a GcFrame
with slots
slots, calls the given closure, and returns its result.
pub fn null_scope<'base, 'julia: 'base, T, F>(
&'julia mut self,
func: F
) -> JlrsResult<T> where
F: FnOnce(&mut NullFrame<'base>) -> JlrsResult<T>,
pub fn null_scope<'base, 'julia: 'base, T, F>(
&'julia mut self,
func: F
) -> JlrsResult<T> where
F: FnOnce(&mut NullFrame<'base>) -> JlrsResult<T>,
Auto Trait Implementations
impl RefUnwindSafe for CCall
impl UnwindSafe for CCall