Wasmtime
engine.hh
Go to the documentation of this file.
1
5#ifndef WASMTIME_ENGINE_HH
6#define WASMTIME_ENGINE_HH
7
8#include <memory>
9#include <wasmtime/config.hh>
10#include <wasmtime/engine.h>
11
12namespace wasmtime {
13
21class Engine {
22 friend class Store;
23 friend class Module;
24 friend class Linker;
25
26 struct deleter {
27 void operator()(wasm_engine_t *p) const { wasm_engine_delete(p); }
28 };
29
30 std::unique_ptr<wasm_engine_t, deleter> ptr;
31
32public:
34 Engine() : ptr(wasm_engine_new()) {}
36 explicit Engine(Config config)
37 : ptr(wasm_engine_new_with_config(config.ptr.release())) {}
38
40 Engine(const Engine &other) : ptr(wasmtime_engine_clone(other.ptr.get())) {}
42 Engine &operator=(const Engine &other) {
43 ptr.reset(wasmtime_engine_clone(other.ptr.get()));
44 return *this;
45 }
46 ~Engine() = default;
48 Engine(Engine &&other) = default;
50 Engine &operator=(Engine &&other) = default;
51
56
58 void is_pulley() const { wasmtime_engine_is_pulley(ptr.get()); }
59};
60
61} // namespace wasmtime
62
63#endif // WASMTIME_ENGINE_HH
Configuration for Wasmtime.
Definition: config.hh:253
Global compilation state in Wasmtime.
Definition: engine.hh:21
Engine & operator=(const Engine &other)
Copies another engine into this one.
Definition: engine.hh:42
Engine(Config config)
Creates an engine with the specified compilation settings.
Definition: engine.hh:36
Engine()
Creates an engine with default compilation settings.
Definition: engine.hh:34
Engine & operator=(Engine &&other)=default
Moves resources from another engine into this one.
void increment_epoch() const
Increments the current epoch which may result in interrupting currently executing WebAssembly in conn...
Definition: engine.hh:55
void is_pulley() const
Returns whether this engine is using Pulley for execution.
Definition: engine.hh:58
Engine(Engine &&other)=default
Moves resources from another engine into this one.
Engine(const Engine &other)
Copies another engine into this one.
Definition: engine.hh:40
Helper class for linking modules together with name-based resolution.
Definition: linker.hh:25
Representation of a compiled WebAssembly module.
Definition: module.hh:27
Owner of all WebAssembly objects.
Definition: store.hh:33
wasm_engine_t * wasmtime_engine_clone(wasm_engine_t *engine)
Create a new reference to the same underlying engine.
void wasmtime_engine_increment_epoch(wasm_engine_t *engine)
Increments the engine-local epoch variable.
bool wasmtime_engine_is_pulley(wasm_engine_t *engine)
Returns whether this engine is using the Pulley interpreter to execute WebAssembly code.
Compilation environment and configuration.
void wasm_engine_delete(wasm_engine_t *)
Deletes an engine.
wasm_engine_t * wasm_engine_new(void)
Creates a new engine with the default configuration.
wasm_engine_t * wasm_engine_new_with_config(wasm_config_t *)
Creates a new engine with the specified configuration.