MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / queue_call

Method queue_call

crates/wasmtime/src/runtime/component/concurrent.rs:2343–2576  ·  view source on GitHub ↗

Add the specified guest call to the "high priority" work item queue, to be started as soon as backpressure and/or reentrance rules allow. SAFETY: The raw pointer arguments must be valid references to guest functions (with the appropriate signatures) when the closures queued by this function are called.

(
        self,
        mut store: StoreContextMut<T>,
        guest_thread: QualifiedThreadId,
        callee: SendSyncPtr<VMFuncRef>,
        param_count: usize,
        result_count: usize,
       

Source from the content-addressed store, hash-verified

2341 /// functions (with the appropriate signatures) when the closures queued by
2342 /// this function are called.
2343 unsafe fn queue_call<T: 'static>(
2344 self,
2345 mut store: StoreContextMut<T>,
2346 guest_thread: QualifiedThreadId,
2347 callee: SendSyncPtr<VMFuncRef>,
2348 param_count: usize,
2349 result_count: usize,
2350 async_: bool,
2351 callback: Option<SendSyncPtr<VMFuncRef>>,
2352 post_return: Option<SendSyncPtr<VMFuncRef>>,
2353 ) -> Result<()> {
2354 /// Return a closure which will call the specified function in the scope
2355 /// of the specified task.
2356 ///
2357 /// This will use `GuestTask::lower_params` to lower the parameters, but
2358 /// will not lift the result; instead, it returns a
2359 /// `[MaybeUninit<ValRaw>; MAX_FLAT_PARAMS]` from which the result, if
2360 /// any, may be lifted. Note that an async-lifted export will have
2361 /// returned its result using the `task.return` intrinsic (or not
2362 /// returned a result at all, in the case of `task.cancel`), in which
2363 /// case the "result" of this call will either be a callback code or
2364 /// nothing.
2365 ///
2366 /// SAFETY: `callee` must be a valid `*mut VMFuncRef` at the time when
2367 /// the returned closure is called.
2368 unsafe fn make_call<T: 'static>(
2369 store: StoreContextMut<T>,
2370 guest_thread: QualifiedThreadId,
2371 callee: SendSyncPtr<VMFuncRef>,
2372 param_count: usize,
2373 result_count: usize,
2374 ) -> impl FnOnce(&mut dyn VMStore) -> Result<[MaybeUninit<ValRaw>; MAX_FLAT_PARAMS]>
2375 + Send
2376 + Sync
2377 + 'static
2378 + use<T> {
2379 let token = StoreToken::new(store);
2380 move |store: &mut dyn VMStore| {
2381 let mut storage = [MaybeUninit::uninit(); MAX_FLAT_PARAMS];
2382
2383 store
2384 .concurrent_state_mut()
2385 .get_mut(guest_thread.thread)?
2386 .state = GuestThreadState::Running;
2387 let task = store.concurrent_state_mut().get_mut(guest_thread.task)?;
2388 let lower = match task.lower_params.take() {
2389 Some(l) => l,
2390 None => bail_bug!("lower_params missing"),
2391 };
2392
2393 lower(store, &mut storage[..param_count])?;
2394
2395 let mut store = token.as_context_mut(store);
2396
2397 // SAFETY: Per the contract documented in `make_call's`
2398 // documentation, `callee` must be a valid pointer.
2399 unsafe {
2400 crate::Func::call_unchecked_raw(

Callers 2

start_callMethod · 0.80
queue_call0Function · 0.80

Calls 15

call_post_returnFunction · 0.85
OkFunction · 0.85
GuestCallClass · 0.85
concurrent_state_mutMethod · 0.80
set_threadMethod · 0.80
enter_instanceMethod · 0.80
exit_instanceMethod · 0.80
handle_callback_codeMethod · 0.80
task_completeMethod · 0.80
cleanup_threadMethod · 0.80
push_high_priorityMethod · 0.80

Tested by

no test coverage detected