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:
@@ -139,6 +139,20 @@ WASM_API_EXTERN wasmtime_error_t *wasmtime_context_add_fuel(wasmtime_context_t *
|
||||
*/
|
||||
WASM_API_EXTERN bool wasmtime_context_fuel_consumed(const wasmtime_context_t *context, uint64_t *fuel);
|
||||
|
||||
/**
|
||||
* \brief Attempt to manually consume fuel from the store.
|
||||
*
|
||||
* If fuel consumption is not enabled via #wasmtime_config_consume_fuel_set then
|
||||
* this function will return an error. Otherwise this will attempt to consume
|
||||
* the specified amount of `fuel` from the store. If successful the remaining
|
||||
* amount of fuel is stored into `remaining`. If `fuel` couldn't be consumed
|
||||
* then an error is returned.
|
||||
*
|
||||
* Also note that fuel, if enabled, must be originally configured via
|
||||
* #wasmtime_context_add_fuel.
|
||||
*/
|
||||
WASM_API_EXTERN wasmtime_error_t *wasmtime_context_consume_fuel(wasmtime_context_t *context, uint64_t fuel, uint64_t *remaining);
|
||||
|
||||
/**
|
||||
* \brief Configres WASI state within the specified store.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user