Class Store
Represents a Wasmtime store.
Inheritance
Namespace: Wasmtime
Assembly: Wasmtime.Dotnet.dll
Syntax
public class Store : IDisposable
Remarks
A Wasmtime store may be sent between threads but cannot be used from more than one thread simultaneously.
Constructors
| Improve this Doc View SourceStore(Engine)
Constructs a new store.
Declaration
public Store(Engine engine)
Parameters
Type | Name | Description |
---|---|---|
Engine | engine | The engine to use for the store. |
Store(Engine, Nullable<Object>)
Constructs a new store with the given context data.
Declaration
public Store(Engine engine, object? data)
Parameters
Type | Name | Description |
---|---|---|
Engine | engine | The engine to use for the store. |
System.Nullable<System.Object> | data | The data to initialize the store with; this can later be accessed with the GetData function. |
Methods
| Improve this Doc View SourceAddFuel(UInt64)
Adds fuel to this store for WebAssembly code to consume while executing.
Declaration
public void AddFuel(ulong fuel)
Parameters
Type | Name | Description |
---|---|---|
System.UInt64 | fuel | The fuel to add to the store. |
ConsumeFuel(UInt64)
Synthetically consumes fuel from this store.
For this method to work fuel consumption must be enabled via WithFuelConsumption(Boolean).
WebAssembly execution will automatically consume fuel but if so desired the embedder can also consume fuel manually to account for relative costs of host functions, for example.
This method will attempt to consume fuel
units of fuel from within this store. If the remaining
amount of fuel allows this then the amount of remaining fuel is returned. Otherwise, a WasmtimeException
is thrown and no fuel is consumed.
Declaration
public ulong ConsumeFuel(ulong fuel)
Parameters
Type | Name | Description |
---|---|---|
System.UInt64 | fuel | The fuel to consume from the store. |
Returns
Type | Description |
---|---|
System.UInt64 | Returns the remaining amount of fuel. |
Exceptions
Type | Condition |
---|---|
WasmtimeException | Thrown if more fuel is consumed than the store currently has. |
Dispose()
Declaration
public void Dispose()
GC()
Perform garbage collection within the given store.
Declaration
public void GC()
GetConsumedFuel()
Gets the fuel consumed by the executing WebAssembly code.
Declaration
public ulong GetConsumedFuel()
Returns
Type | Description |
---|---|
System.UInt64 | Returns the fuel consumed by the executing WebAssembly code or 0 if fuel consumption was not enabled. |
GetData()
Retrieves the data stored in the Store context
Declaration
public object? GetData()
Returns
Type | Description |
---|---|
System.Nullable<System.Object> |
SetData(Nullable<Object>)
Replaces the data stored in the Store context
Declaration
public void SetData(object? data)
Parameters
Type | Name | Description |
---|---|---|
System.Nullable<System.Object> | data |
SetEpochDeadline(UInt64)
Configures the relative deadline at which point WebAssembly code will trap.
Declaration
public void SetEpochDeadline(ulong ticksBeyondCurrent)
Parameters
Type | Name | Description |
---|---|---|
System.UInt64 | ticksBeyondCurrent |
SetWasiConfiguration(WasiConfiguration)
Configures WASI within the store.
Declaration
public void SetWasiConfiguration(WasiConfiguration config)
Parameters
Type | Name | Description |
---|---|---|
WasiConfiguration | config | The WASI configuration to use. |