Skip to main content

invoke_wrapper

Function invoke_wrapper 

Source
pub fn invoke_wrapper<'a, F>(
    wrapped: F,
) -> Box<dyn Fn() -> ForeignInvokeResult + Send + Sync + 'a>
where F: Fn() + UnwindSafe + Clone + Send + Sync + 'a,
Expand description

Wrap a contract closure in the catch site that maps its panics to Thruput invoke error codes.

Sync is the load-bearing bound: the wrapper is stored on the contract and invoked through a shared reference from whichever thread resumed the coroutine, so &F has to be usable there. Cloning an Rc capture from two threads at once would race its refcount, and Sync rejects that at the registration site instead. Send goes with it because the captures travel with the contract’s heap allocation.