Add Store::consume_fuel to manually consume fuel (#3352)
This can be useful for host functions that want to consume fuel to reflect their relative cost. Additionally it's a relatively easy addition to have and someone's asking for it! Closes #3315
This commit is contained in:
@@ -145,6 +145,17 @@ pub extern "C" fn wasmtime_context_fuel_consumed(store: CStoreContext<'_>, fuel:
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wasmtime_context_consume_fuel(
|
||||
mut store: CStoreContextMut<'_>,
|
||||
fuel: u64,
|
||||
remaining_fuel: &mut u64,
|
||||
) -> Option<Box<wasmtime_error_t>> {
|
||||
crate::handle_result(store.consume_fuel(fuel), |remaining| {
|
||||
*remaining_fuel = remaining;
|
||||
})
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct wasmtime_interrupt_handle_t {
|
||||
handle: InterruptHandle,
|
||||
|
||||
Reference in New Issue
Block a user